Skip to content
Calcrivo

Socket Buffer Calculator

Total socket buffer memory across all connections, checked against net.core.rmem_max.

Inputs

Linux default net.ipv4.tcp_rmem middle value is 87380

Linux default net.ipv4.tcp_wmem middle value is 16384

Total Socket Buffer Memory (MB)

494.79

Memory per Connection (rmem + wmem, bytes)

103,764

Per-Socket rmem Exceeds net.core.rmem_max?

false

rmem Headroom Below rmem_max (bytes)

125,612

Step by step

  1. Values used

    Concurrent Connections = 5,000; Receive Buffer per Socket (bytes) = 87,380; Send Buffer per Socket (bytes) = 16,384; net.core.rmem_max (bytes) = 212,992

  2. Total socket buffer memory

    total_memory = connections × (rmem + wmem)

  3. Total Socket Buffer Memory (MB)

    = 494.79

  4. Memory per Connection (rmem + wmem, bytes)

    = 103,764

  5. Per-Socket rmem Exceeds net.core.rmem_max?

    = No

  6. rmem Headroom Below rmem_max (bytes)

    = 125,612

How it works

Every open TCP socket reserves separate receive (rmem) and send (wmem) buffer memory, and at scale — thousands of concurrent connections on a busy server — the aggregate memory committed to socket buffers alone can become a significant fraction of total system RAM, which is why per-socket buffer size and expected connection count both matter for capacity planning. The system-wide net.core.rmem_max (and wmem_max) sets a hard ceiling that per-socket auto-tuning or explicit setsockopt(SO_RCVBUF) calls cannot exceed, so a per-socket target above that ceiling is silently capped rather than honored.

Formula

Total socket buffer memory

total_memory = connections × (rmem + wmem)

C
concurrent connections
rmem
receive buffer per socket
wmem
send buffer per socket

Frequently Asked Questions

How do I check current rmem/wmem defaults and maximums on Linux?

`sysctl net.ipv4.tcp_rmem net.ipv4.tcp_wmem` shows the three-value (min, default, max) auto-tuning ranges for TCP sockets; `sysctl net.core.rmem_max net.core.wmem_max` shows the hard system-wide ceilings that bound auto-tuning and explicit setsockopt calls alike.

Does every socket actually use its full configured buffer size?

No — Linux's TCP auto-tuning dynamically grows each socket's buffer between the configured min and max based on observed throughput and available memory, so idle or low-throughput connections typically use far less than the maximum, making this calculator's flat per-connection estimate a worst-case ceiling rather than typical usage.

What's the risk of setting rmem/wmem too high system-wide?

With very high concurrent connection counts, aggressively large per-socket buffers can exhaust system memory or trigger the kernel's memory pressure/OOM handling under load — buffer sizing should be based on actual bandwidth-delay product needs (see the Network Buffer Size Calculator) rather than maximized blindly.

You might also need