memory of a public node with 1000 connections: measured, GOMEMLIMIT in the manifest

cmd/allmende-conns opens many small libp2p clients to one node. A real --public node: 35 MB idle, 131 MB with 1000 connections, 156 MB at the peak with 100 listings flooded to all of them; the limit refused the 1001st. The StatefulSet sets GOMEMLIMIT=400MiB under its 512Mi limit as a safety net.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AeFqV96dVeBX94inzcgZKw
This commit is contained in:
2026-11-19 00:58:45 +01:00
co-authored by Claude Sonnet 5.5
parent 59973cbf43
commit 6e37a2c654
4 changed files with 138 additions and 6 deletions
+10 -2
View File
@@ -706,8 +706,16 @@ Findings (see "What is left" in SPECS.md for the open ones):
GB, fewer in a small container): with 200 nodes, 12 never got a single peer.
A `--public` node now accepts 1000 inbound connections (`--max-conns`
changes it; `-1` restores libp2p's default), and the table above shows the
result. Not measured: the memory of a seed holding 1000 connections against
the 512 MiB limit in `k8s/base/statefulset.yaml`.
result. **Memory with 1000 connections** (`cmd/allmende-conns`, one real
`--public` node, 1000 small libp2p clients on the same machine, each
subscribed to the region's topic): 35 MB idle, 131 MB with the 1000
connections (about 100 KB each), 156 MB at the peak after 100 listings were
published and flooded to all 1000 (the Go heap on Linux, `VmHWM`). A
further 100 connection attempts were refused as intended (1000 connected,
100 failed). That is about 30% of the 512 MiB pod limit. Real peers do more
than these clients (identify, DHT queries, relayed streams), so the
manifest also sets `GOMEMLIMIT=400MiB`, which makes the Go runtime collect
harder as the limit nears instead of being killed by it.
2. **Peer limits are crude.** The first run had no peer scoring: the attacker
stayed connected to all 10 nodes it dialed after 500 bad messages. Now every
node counts, per relaying peer and minute, the messages it gets (over 1200