-
Notifications
You must be signed in to change notification settings - Fork 493
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
IncomingConnectionsLimit limits short lived connections #5766
Comments
I believe the IncomingConnectionsLimit is also there to limit and provision resource usage in general, for example to ensure you have enough file descriptors at startup time in daemon/algod/server.go. Allowing unlimited connections on the gossip port could result in exhausting the FD limit, or using too much memory, while serving many concurrent non-websocket HTTP requests. To support monitoring when IncomingConnectionsLimit is reached, I could imagine having two tiers of limits, instead of just one. However since even a higher "max connections" vs "max websocket connections" limit could still be exhausted, perhaps another approach would be some simple authentication (e.g. using an HTTP header) to let a monitoring check bypass the IncomingConnectionsLimit. Also, since websockets, block, and catchpoint file requests all use different URLs, these different limits and authorization techniques for each type of request could probably also be implemented inside a reverse HTTP proxy. I don't know if many node operators run behind proxies. In all I'm not sure it is a good idea to allow unlimited parallel HTTP requests, and preserving a general capability to apply connection limits seems important. |
IncomingConnectionsLimit is set as an Accept socket limit on gossip port - so TCP stack rejects any requests when gossip is already at IncomingConnectionsLimit - including catchup/block/health There are separate checks later in the code path that make sure IncomingConnectionsLimit is not exceeded. The REST/Websocket limits are enforced in other places. |
But the REST API doesn't use the NetAddress ("gossip") port, it has its own port (EndpointAddress, implemented in daemon/algod/api/server and provided with a RejectingLimitListener in daemon/algod/server.go)? AFAIK the websocket port doesn't share any resources with the REST API port? |
It is confusing because the NetAddress port is used to serve the gossip HTTP path ( |
I think you are maybe thinking along the lines of having separate limits for |
I do not care about the REST API /v2/ endpoints. Only solving a relay issue here. IncomingConnectionsLimit is supposed to limit long lived connections and this websocket connections limit (up to IncomingConnectionsLimit) is enforced later in the code path. The same socket serves short lived connections - if not for catchups and blocks then for stuff like the AF relay monitoring. If I try to protect my relay against an overload by long lived gossip/websocket connections I also make it unavailable to the AF monitoring and basic catchup/block functions. This might not be critical now but once relays go P2P users might want to set the limit low but still allow others to bootstrap off off them while the gossip limiter is in place. So either change the description for IncomingConnectionsLimit to ANY connections on gossip port or add extra room on the socket Accept to allow for vital short lived functions and make IncomingConnectionsLimit indeed limit long lived connections only. |
You are right that the config description is wrong, You could also consider adding a separate limit like |
Closing this in favor of the solution merged with #6009 |
Status
IncomingConnectionsLimit param is designed to limit longed lived connections (websocket) only.
With the current implementation is rejects requests for catchups and blocks on gossip port.
Also makes it impossible to monitor relay health if IncomingConnectionsLimit is reached.
Expected
IncomingConnectionsLimit should limit concurrent websocket connections only.
The text was updated successfully, but these errors were encountered: