Skip to content

Commit

Permalink
docs: resource management autoscaling
Browse files Browse the repository at this point in the history
  • Loading branch information
lidel committed Jan 19, 2023
1 parent b88d580 commit 15196f0
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions docs/libp2p-resource-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,29 @@ There is a go-libp2p issue ([#1928](https://github.com/libp2p/go-libp2p/issues/1
### How does the resource manager (ResourceMgr) relate to the connection manager (ConnMgr)?
As discussed [here](https://github.com/libp2p/go-libp2p/tree/master/p2p/host/resource-manager#connmanager-vs-resource-manager)
these are separate systems in go-libp2p.
Kubo also configures the ConnMgr separately from ResourceMgr. However sanity checks may lock them together.

`Swarm.ConnMgr.HighWater` needs to be `Swarm.ResourceMgr.Limits.System.ConnsInbound` for the configuration to make sense.
This makes ConnMgr kick in and cleanup connections based on connection priorities before the hard limits of the ResourceMgr are applied.
Kubo maintains separate configuration for ConnMgr and ResourceMgr but the
limits set in each may be logically linked. Kubo may also run additional sanity
checks to ensure that the limits make sense in relation to each other.

For example, `Swarm.ConnMgr.HighWater` needs to be set lower than
`Swarm.ResourceMgr.Limits.System.ConnsInbound` in order for the configuration
to be valid. This allows the ConnMgr to manage and clean up connections based
on their priorities before the hard limits set by the ResourceMgr are reached.

If `Swarm.ConnMgr.HighWater` is greater than `Swarm.ResourceMgr.Limits.System.ConnsInbound`,
existing low priority idle connections can prevent new high priority connections from being established.
The ResourceMgr doesn't know that the new connection is high priority and simply blocks it because of the limit its enforcing.

To ensure this happen with the default config kubo's autoscalling will make `Swarm.ResourceMgr.Limits.System.ConnsInbound` equal to
`Swarm.ConnMgr.HighWater` times two, it will also scale `Swarm.ResourceMgr.Limits.System.StreamsInbound` to keep the same streams to
connections ratio.
Kubo's autoscaling feature will automatically set the default
`Swarm.ResourceMgr.Limits.System.ConnsInbound` value to twice the value of
`Swarm.ConnMgr.HighWater`, and not less than `DefaultResourceMgrMinInboundConns`.
Additionally, it will adjust the
`Swarm.ResourceMgr.Limits.System.StreamsInbound` value to maintain a consistent
ratio of streams to connections.

The default limits should be sufficient for most users, however, it is also
possible for users to set custom limits in the configuration file if needed.

### How does one see the Active Limits?
A dump of what limits are actually being used by the resource manager ([Computed Default Limits](#computed-default-limits) + [User Supplied Override Limits](#user-supplied-override-limits))
Expand Down

0 comments on commit 15196f0

Please sign in to comment.