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

Limit the number of accepted connections #1391

Closed
mrBliss opened this issue Jan 3, 2020 · 9 comments
Closed

Limit the number of accepted connections #1391

mrBliss opened this issue Jan 3, 2020 · 9 comments
Assignees
Labels
byron Required for a Byron mainnet: replace the old core nodes with cardano-node
Milestone

Comments

@mrBliss
Copy link
Contributor

mrBliss commented Jan 3, 2020

At the moment, if a node runs out of file handles or other resources because too many clients have connected to it, it will shut down with an error. Clients will try the next node, which will also run out of resources and shut down, then they'll go to the next node and so on, leading to a cascading failure.

Instead, it should decline the new client so that it can keep on serving the connected clients. The client should wait or try the next server so that the network is unaffected.

To figure out the maximum number of clients, we should figure out a conservative maximum bound on the resources required to serve a client, see #1278.

Related: #1384 #1378 (comment)

@mrBliss mrBliss added networking byron Required for a Byron mainnet: replace the old core nodes with cardano-node consensus issues related to ouroboros-consensus labels Jan 3, 2020
@mrBliss mrBliss added this to the S4 2020-01-16 milestone Jan 6, 2020
@mrBliss mrBliss self-assigned this Jan 6, 2020
@coot coot modified the milestones: S4 2020-01-16, S5 2020-01-30 Jan 9, 2020
@coot
Copy link
Contributor

coot commented Jan 9, 2020

To account how many resources are available for downstream peers, we need to estimate how many resources are taken by upstream ones. Currently we have a static configuration which decides how many upstream peers we will connect to, with the peer2peer governor this will change but still we should be able to have a policy which governs that (@dcoutts).

@coot coot self-assigned this Jan 9, 2020
@coot
Copy link
Contributor

coot commented Jan 9, 2020

I assigned myself to work on the network level interface.

@coot coot modified the milestones: S5 2020-01-30, S6 2020-02-13 Jan 17, 2020
@coot coot modified the milestones: S6 2020-02-13, S7 2020-02-27 Jan 31, 2020
@mrBliss
Copy link
Contributor Author

mrBliss commented Feb 3, 2020

@coot This ticket is only about accepting a limited number of accepted clients. We can use a relatively low value for it that is surely safe for now, e.g., 20. Such a limit must be in place before the release, otherwise the node will crash when too many clients connect.

After adding such a limit, we can do more precise accounting for resources, and increase the limit based on that, but that's not what this ticket is about. We have IntersectMBO/ouroboros-consensus#736 and IntersectMBO/ouroboros-consensus#735 for that.

IMO, the network is the most logical place to have such a limit.

@coot Do you think the network team will be able to add such a limit in this sprint?

@mrBliss mrBliss modified the milestones: S7 2020-02-27, S6 2020-02-13 Feb 3, 2020
@edsko
Copy link
Contributor

edsko commented Feb 10, 2020

Blocked on #1473.

@edsko
Copy link
Contributor

edsko commented Feb 10, 2020

This is blocked on networking improvements, and the networking team tells me that this won't be done this sprint. Moving to the next.

@edsko edsko modified the milestones: S6 2020-02-13, S7 2020-02-27 Feb 10, 2020
@edsko
Copy link
Contributor

edsko commented Feb 11, 2020

This will be handled network side, so consensus is not involved.

@mrBliss mrBliss removed the consensus issues related to ouroboros-consensus label Feb 11, 2020
@coot coot assigned avieth and unassigned coot Feb 17, 2020
@coot coot modified the milestones: S7 2020-02-27, S9 2020-03-26 Feb 28, 2020
@coot coot changed the title Limit the number of accepted clients Limit the number of accepted connections Mar 2, 2020
@dcoutts
Copy link
Contributor

dcoutts commented Mar 12, 2020

@coot I suspect giving the timing we will need to implement this for the existing connection manager, and merge the new p2p-governor based connection manager after, targeting the Shelley testnet.

@coot
Copy link
Contributor

coot commented Mar 16, 2020

@dcoutts, ok - I am working now on Windows issues (CI, and finishing the re-factorization of Win32-network) and then I'll work on this issue.

@coot
Copy link
Contributor

coot commented Mar 20, 2020

PR #1831

iohk-bors bot added a commit that referenced this issue Mar 23, 2020
1831: Policy for lmitting number of accepted connections r=coot a=coot

This pr implements a policy which allows us to limit the number of accepted connections, addressing the issue #1391.

There are two thresholds:
- `acceptedConnectionsHardLimit`
- `acceptedConnectionsSoftLimit`
And a delay
- `acceptedConnectionsDelay`

If we are below the soft limit, we accept connections without any delay;
Above the *soft limit*, we start rate limiting using a linear regression of the `acceptedConnectionsDelay`.
If we hit the hard limit, then we wait until the number of connections drops
(but not shorted than `acceptedConnectionsDelay`).   (We could add a third
threshold to drop below that, but we should be good for now with this policy).

This is a standalone component, so it will be easy to bring it to
`connection-manager`.

Todo:
- [x] add a trace

Co-authored-by: Marcin Szamotulski <[email protected]>
@coot coot closed this as completed Mar 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
byron Required for a Byron mainnet: replace the old core nodes with cardano-node
Projects
None yet
Development

No branches or pull requests

5 participants