Calculate optimal socket send/receive buffer sizes based on bandwidth and latency.
To keep a TCP connection's throughput saturating the available bandwidth, the socket buffer must be at least as large as the bandwidth-delay product (BDP) — the volume of data that can be in flight before the first acknowledgment returns across the round-trip. Undersized buffers force the sender to stall waiting for ACKs, capping throughput well below the link's real capacity. Because each concurrent connection needs its own buffer allocation, the total kernel memory committed to networking scales linearly with connection count, which matters when sizing net.core.rmem_max/wmem_max on a server handling many simultaneous sockets.
Bandwidth-delay product buffer size
buffer = bandwidth_Mbps × RTT_ms / 8 × 1000
Total kernel memory
total = buffer_per_connection × connections
Bandwidth is conventionally measured in bits per second (Mbps) while buffer sizes are measured in bytes, so dividing by 8 converts bits to bytes before multiplying by the round-trip time to get a byte-denominated buffer size.
Oversized buffers waste kernel memory across many connections and can increase latency under congestion (a phenomenon known as bufferbloat, where packets queue for longer than necessary before being dropped or delivered), so buffers should be sized close to the BDP rather than made arbitrarily large.
The relevant sysctls are net.core.rmem_max and net.core.wmem_max for the system-wide ceiling, and net.ipv4.tcp_rmem / net.ipv4.tcp_wmem for the per-socket min/default/max triplet — set the max values at or above your calculated per-connection buffer size.