File tree 2 files changed +22
-0
lines changed 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -110,6 +110,10 @@ const DefaultConnMgrGracePeriod = time.Second * 20
110
110
// type.
111
111
const DefaultConnMgrType = "basic"
112
112
113
+ // DefaultResourceMgrMinInboundConns is a MAGIC number that probably a good
114
+ // enough number of inbound conns to be a good network citizen.
115
+ const DefaultResourceMgrMinInboundConns = 800
116
+
113
117
func addressesConfig () Addresses {
114
118
return Addresses {
115
119
Swarm : []string {
Original file line number Diff line number Diff line change @@ -186,5 +186,23 @@ Run 'ipfs swarm limit all' to see the resulting limits.
186
186
187
187
defaultLimitConfig := scalingLimitConfig .Scale (int64 (maxMemory ), int (numFD ))
188
188
189
+ // Simple checks to overide autoscaling ensuring limits make sense versus the connmgr values.
190
+ // There are ways to break this, but this should catch most problems already.
191
+ // We might improve this in the future.
192
+ // See: https://github.com/ipfs/kubo/issues/9545
193
+ if cfg .ConnMgr .Type == nil || cfg .ConnMgr .Type .String () != "none" {
194
+ maxInboundConns := int64 (defaultLimitConfig .System .ConnsInbound )
195
+ if connmgrHighWaterTimesTwo := cfg .ConnMgr .HighWater .WithDefault (config .DefaultConnMgrHighWater ) * 2 ; maxInboundConns < connmgrHighWaterTimesTwo {
196
+ maxInboundConns = connmgrHighWaterTimesTwo
197
+ }
198
+
199
+ if maxInboundConns < config .DefaultResourceMgrMinInboundConns {
200
+ maxInboundConns = config .DefaultResourceMgrMinInboundConns
201
+ }
202
+
203
+ defaultLimitConfig .System .StreamsInbound = int (maxInboundConns * int64 (defaultLimitConfig .System .StreamsInbound ) / int64 (defaultLimitConfig .System .ConnsInbound ))
204
+ defaultLimitConfig .System .ConnsInbound = int (maxInboundConns )
205
+ }
206
+
189
207
return defaultLimitConfig , nil
190
208
}
You can’t perform that action at this time.
0 commit comments