-
Notifications
You must be signed in to change notification settings - Fork 58
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
algorithm: freeSockets pop/shift #8
Comments
@syndr0m good point! Can you impl this with a pr? |
@syndr0m this sounds awesome! |
Any progress? |
I think use pop instead of shift is enough |
Did this ever happen? |
fyi, the referenced code is not currently in this project: https://github.com/nodejs/node/blob/master/lib/_http_agent.js#L165 You'd probably need to replace addRequest and curry the selected algorithm into the original'ish version. A quick thought here... While it would be nice to be able to have the algorithm choice, I believe the intended behavior of keep-alives is to keep connections alive to reduce the overhead of establishing connections. The max number of free connections is configurable, so I'm not sure if this functionality has a ton of value. |
Maybe related/solved by this nodejs/node#33278 ? |
the current algorithm maximize the number of sockets opened, by re-using the first stacked free socket using freesockets.shift()
@see https://github.com/node-modules/agentkeepalive/blob/master/lib/_http_agent.js#L170
an alternative could be to use freesockets.pop() to minimize the number of sockets opened
implementation:
I tested this for 1K request/s, it divided the pool size by 5.
The text was updated successfully, but these errors were encountered: