最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - node.js what happens when maxSockets are reached? - Stack Overflow

programmeradmin1浏览0评论

I was wondering what happens when maxSockets is reached?

If I'm using a service that allows me to create a custom http.Agent and I specify maxSockets to 1. What happens when I try to issues multiple concurrent requests?

Will each request beyond the initial block until the initial is plete?? Then the socket would bee available to the next request? and all others block? I would certainly assume so, but was not able to find anything in the docs specifically, and am brand new to socket programming.

I was wondering what happens when maxSockets is reached?

If I'm using a service that allows me to create a custom http.Agent and I specify maxSockets to 1. What happens when I try to issues multiple concurrent requests?

Will each request beyond the initial block until the initial is plete?? Then the socket would bee available to the next request? and all others block? I would certainly assume so, but was not able to find anything in the docs specifically, and am brand new to socket programming.

Share Improve this question asked Nov 19, 2015 at 15:16 dm03514dm03514 56k18 gold badges117 silver badges147 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

After maxSockets are in use, additional requests get queued until an active request pletes and a socket is freed up to be used, at which point a pending request from the queue would be sent on the newly-freed socket.

Note this is technically queueing not blocking - the CPU and event loop continue to do useful work during this process.

Note also there is a maxSockets and queue on a per-origin ("host:port") basis (similar to browsers).

Also note that the default maxSockets is Infinity.

发布评论

评论列表(0)

  1. 暂无评论