ChainSafe / gossamer

🕸️ Go Implementation of the Polkadot Host
https://chainsafe.github.io/gossamer
GNU Lesser General Public License v3.0
433 stars 114 forks source link

Max peers config has no effect #4272

Open haikoschol opened 3 weeks ago

haikoschol commented 3 weeks ago

Describe the bug

The default value for the --max-peers CLI flag is 50. On a long-running bare metal Westend node, Grafana shows 479 under "Network total connected peers" and 957 under "Network total node connections". Either the configuration setting has no effect or the metrics are reported incorrectly.

Expected Behavior

The node should maintain no more than the maximum number of peer connections configured.

Current Behavior

The number of peers/connections keeps rising for a while until it stabilizes on a value much higher than the configured maximum. The number it stabilizes on seems to be correlated to the CPU/memory resources of the node.

To Reproduce

Steps to reproduce the behavior:

  1. run Gossamer without passing --max-peers to use the default of 50
  2. wait a while
  3. check the number of peers with curl -s localhost:9876/metrics | grep peer_count_total

Specification

haikoschol commented 2 weeks ago

This might be a symptom of #4293.

haikoschol commented 1 week ago

This might be a symptom of #4293.

It's not:

$ grep peers config.toml
# Minimum number of peers to connect to
min-peers = 5
# Maximum number of peers to connect to
max-peers = 50
# Comma separated list of peers to always keep connected to
persistent-peers = ""

This was on a machine that reports 316 "Network total connected peers" and 735 "Network total node connections".

However, those numbers are apparently wrong as well.

Number of all TCP connections of the gossamer process:

$ lsof -n -P -iTCP  | grep gossamer | wc -l
201

Number of all TCP connections in the ESTABLISHED state:

$ lsof -n -P -iTCP -sTCP:ESTABLISHED | grep gossamer | wc -l
195

So it seems that both the prometheus metrics are wrong and the config value is not honored by the network service.