Skip to content

httpAgent.absoluteMaxSockets  #31942

Closed
Closed
@seansd-zz

Description

@seansd-zz

We are trying to ensure the maximum number of active connections from NodeJS to backend systems is maintained. httpAgent.maxSockets behaves at a "per origin" level which is also dynamic and not completely deterministic. This makes it difficult to create logic and patterns as the number of connections grows. Instead we propose absoluteMaxSockets (or some other clever name), that enforces a maximum number of active sockets regardless of the origin.

Doing this now is possible in the user space, but requires a great deal of code and logic to bind to each and every socket connection event and do the counting and enforcement, etc.

Describe the solution you'd like
Assuming httpAgent.absoluteMaxSockets is implemented, if the number of open sockets across all origins grows beyond this number, the http agent would first attempt to check and see if any sockets can be closed, and if so attempt to close those sockets prior to opening a new one.
Assuming one cannot be open, an exception would be thrown at the time a request is made since a new socket connection cannot be opened.

Describe alternatives you've considered
As mentioned, we could implement this in user space, but it's tricky and cumbersome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.httpIssues or PRs related to the http subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions