Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: http.Agent, reuse single socket vs new socket for each request #36463

Closed
ha-douken opened this issue Dec 9, 2020 · 3 comments
Closed

doc: http.Agent, reuse single socket vs new socket for each request #36463

ha-douken opened this issue Dec 9, 2020 · 3 comments
Labels
doc Issues and PRs related to the documentations. http Issues or PRs related to the http subsystem.

Comments

@ha-douken
Copy link

ha-douken commented Dec 9, 2020

📗 http.Agent, reuse single socket vs new socket for each request

http.Agent documentation says
[…] It maintains a queue of pending requests for a given host and port, reusing a single socket connection for each until the queue is empty […]
Which is in contrast to the description of the maxSockets option
[…] Each request will use a new socket until the maximum is reached. []

So will it reuse a single socket connection or use a new socket for each request?

@ha-douken ha-douken added the doc Issues and PRs related to the documentations. label Dec 9, 2020
@ha-douken ha-douken changed the title doc: https://nodejs.org/api/http.html#http_class_http_agent Dec 9, 2020
@ha-douken ha-douken changed the title https://nodejs.org/api/http.html#http_class_http_agent doc: http.Agent, reuse single socket vs new socket for each request Dec 9, 2020
@Trott Trott added the http Issues or PRs related to the http subsystem. label Dec 12, 2020
@mmomtchev
Copy link
Contributor

@ha-douken In both cases - wheter keepAlive is enabled or not, maxSockets puts an upper limit to the maximum allowed concurrently running sockets. When a new request is made, whether a new socket is created, or an idle one is pulled from the pool, it is still the same limit that applies - only simultaneously running requests count.

@ha-douken
Copy link
Author

ha-douken commented Dec 16, 2020

The question is not about keepAlive and connection pools.
The question is, when a request is initiated is:
a) the request put into a pending-request-queue which is assigned to one specific connection, or
b) a new connection created dedicated to handle just this request
The docs state both which is contradictory.

I am not putting connection pools and keepAlive into the picture because it will not help the question.

@ha-douken
Copy link
Author

ha-douken commented Jan 18, 2021

Oh, darn. Does "[...] reusing a single socket connection for each [...]" mean that there is a connection per request? I read it as "the same connection is reused for each request" but maybe that is just me lacking proper english?

ruyadorno pushed a commit that referenced this issue Jan 22, 2021
PR-URL: #36941
Fixes: #36463
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
ruyadorno pushed a commit that referenced this issue Jan 25, 2021
PR-URL: #36941
Fixes: #36463
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
targos pushed a commit that referenced this issue May 1, 2021
PR-URL: #36941
Fixes: #36463
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. http Issues or PRs related to the http subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants