Uncovering Hidden TCP Throttling in the Linux Kernel cdn77.com · 18 points · 0 c...
HN Best 200 @best
Uncovering Hidden TCP Throttling in the Linux Kernel cdn77.com · 18 points · 0 comments · HN thread
TL;DR CDN77 describes how a slow-download problem on its edge servers, appearing randomly only on nginx cache-miss connections, was traced to the Linux kernel's cgroup memory-pressure logic. A per-cgroup pressure flag, set when reclaim frees less than about 40% of a tiny 2 MB scan window, throttled TCP receive windows for every socket in the cgroup. Their workaround was moving nginx to the root cgroup, and they contributed a sock_throttled counter that appeared in Linux 6.19.
- Customers saw download speeds collapse on some connections for hours, then recover on their own; curl on the same server was fast, so only nginx was affected, and only on cache misses.
- Tracing with bpftrace showed rcv_ssthresh was pinned at four times the advertised MSS, which only happens via tcp_adjust_rcv_ssthresh() under memory pressure.
- SNMP counters reported zero memory pressures, yet tcp_under_memory_pressure() returned true because it also checks the socket's cgroup, which systemd enables by default via the memory controller.
- vmpressure() sets a per-cgroup flag for one second when reclaim frees less than about 40% of pages scanned in a roughly 2 MB window, regardless of how much free RAM the machine has.
- The temporary fix was moving nginx processes into the root cgroup, which is exempt from this check; the team upstreamed a sock_throttled counter in memory.events, available since Linux 6.19.
- The article promises a proper fix in a later post but does not yet describe one.
Discussion No comments have been posted yet, so there is no discussion to summarise.