-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
ResourceManager: Adjust inbound connection limits depending on memory. #9593
Conversation
40f6876
to
75de158
Compare
Just checking in, any chance we're landing this today for the v0.18.1 release? |
@galargh I hope to land it today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments. Logic is good. Thanks!
75de158
to
c98a9fc
Compare
@@ -1843,7 +1843,7 @@ This value is also used to scale the limit on various resources at various scope | |||
when the default limits (discussed in [libp2p resource management](./libp2p-resource-management.md)) are used. | |||
For example, increasing this value will increase the default limit for incoming connections. | |||
|
|||
Default: `[TOTAL_SYSTEM_MEMORY]/4` | |||
Default: `[TOTAL_SYSTEM_MEMORY]/2` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💭 (not familiar with prior discussions, someone else needs to review, but adding comment in favor of this change)
👍 I know @2color run into issues when he was running on a box that had 2 GB RAM on https://fly.io/ box, and his libp2p stack only got 1/4 (512MB).
This should improve default behavior in such setups (allocating 1GB).
This is in response to libp2p/go-libp2p#2010 for simplification I think we want to be able to do this for Kubo.
I believe will allow the resource manager to get out of the way more but still protect against script-kiddies opening many connections/streams against a node.
In order for this work, established (non-transient) connections will need to register memory usage with the resource manager/accountant, ideally across all transports and muxers. Per libp2p/go-libp2p#2010 (comment), there are some cases where an established libp2p connection doesn't increase memory accounted for by the resource manager/accountant. In the meantime, we can set System.ConssInbound based on ResourceMgr.MaxMemory and then strip this out when libp2p/go-libp2p#2010 lands.
Change tested checking that we do not OOM after a stream flooding attack. Everything working as expected.
Updated defaults values to use totalMemory/2
It closes #9602