A CDN edge server with hundreds of gigabytes of free RAM slowed to a crawl one night, just before 3 a.m., and stayed there for five hours. Nobody touched it. Around 8 a.m. it recovered on its own.
On that same box, at that same moment, curl pulled the same content at full speed. Only nginx was slow.
That is the setup of Uncovering Hidden TCP Throttling in the Linux Kernel, written by Daniel Sedlak, a performance engineer at CDN77. It reached #8 on the Hacker News front page this week with 296 points. I read it, then read the kernel source and the upstream commits around it. The short version: the throttle is real, it has been in the kernel since 2016, and since Linux 6.19 one line in one file tells you whether it is hitting your servers.
The dead ends
The symptoms fit none of the usual stories. The slowdown came and went by itself, hit only some connections, only on cache misses (when the edge has to fetch from the layer above it), and only in nginx. A reboot made it go away for a while.
CDN77 worked through the list you would write yourself: ISP and transit trouble (it showed up in several regions), the tcp_rmem, tcp_wmem and tcp_mem sysctls, nginx buffering, disk stalls, CPU, memory, kernel logs, version drift. Healthy neighbors had the same configs and the same versions.
Next they suspected nginx and traced its read and epoll syscalls: arguments, return codes, durations. nginx read as fast as it could, until EAGAIN, every time. Userspace was clean.
The field that gave it away
So they went into the kernel. They hung a bpftrace kprobe on tcp_rcv_established, the receive path for an open connection, and printed fields from each socket's struct tcp_sock: the receive window, the congestion window, the advertised MSS, rcv_ssthresh.
rcv_ssthresh sat at exactly four times the advertised MSS. That number is a fingerprint. In the kernel's window growth code, a socket the stack believes is under memory pressure stops growing its receive window and gets clamped to 4 * advmss instead.
But the system-wide counters swore there was no pressure at all. This transcript is from the CDN77 post:
$ nstat -z | grep Pressure TcpExtTCPMemoryPressures 0 0.0 TcpExtTCPMemoryPressuresChrono 0 0.0 The flag lives on the cgroup
The catch is in tcp_under_memory_pressure(). Before it looks at the global TCP memory state, it asks whether the socket's memory cgroup is under pressure. If the cgroup says yes, every socket charged to it is treated as starved, whatever the machine-wide numbers say. nstat only counts the global kind, so it reads zero.
A cgroup gets that mark from vmpressure(), which grades reclaim efficiency, not free memory. Each time reclaim has scanned 512 pages of a cgroup (2 MiB with 4 KiB pages), it compares pages freed to pages scanned. A bad ratio sets a socket-pressure deadline one second out on that cgroup. The root cgroup is skipped.
I copied the level math from mm/vmpressure.c into a few lines of Python to see exactly where the line sits (output trimmed):
scanned reclaimed freed pressure level sockets throttled? 512 410 80.1% 19 low no 512 205 40.0% 59 low no 512 204 39.8% 60 medium yes, 1 s 512 50 9.8% 90 medium yes, 1 s Free 204 of 512 scanned pages and every socket in that cgroup is clamped for a second. Free memory appears nowhere in the formula. On a 512 GiB machine, that 2 MiB window is 1/262,144 of RAM. A cache server whose page cache is full of hot pages fails the test easily: reclaim keeps walking pages that are in use and frees few of them.
As far as I can tell, that also explains the curl paradox. The flag belongs to nginx's cgroup, where its cache pages are charged. A curl started from an SSH session runs in a different cgroup and never sees it.
What does the clamp cost? With the common 1,448-byte MSS, 4 * advmss is 5,792 bytes. A receive window that small caps one connection at window divided by round-trip time:
RTT 5 ms: ceiling 1158.4 kB/s = 9.27 Mbit/s RTT 20 ms: ceiling 289.6 kB/s = 2.32 Mbit/s RTT 50 ms: ceiling 115.8 kB/s = 0.93 Mbit/s That is my arithmetic, a ceiling rather than a measurement. For a CDN fetching a cache miss from another continent, it is an outage that looks like a slow network.
What changed upstream
The behavior is old. Johannes Weiner wired vmpressure to socket pressure in January 2016 (Linux 4.5), and his commit message said it "will likely need finetuning for a wider variety of workloads." On HN, rstuart4133 put its age at eleven years.
Three things have moved since:
- A counter, Linux 6.19.
memory.eventsgainedsock_throttled, the number of times sockets in that cgroup hit the throttle. The commit is by Shakeel Butt, with Daniel Sedlak as a reviewer, and its message lists what throttling does: clamped windows, buffers that cannot grow, a pruned out-of-order queue. - A narrow fix, Linux 7.2. JP Kobryn at Meta stopped high-order reclaim from setting socket pressure. On one Meta host with about 15 GB available, 19% of TCP connections sat at the minimum receive window; after the patch, none did. It removes one trigger (kswapd chasing order-7 pages on a fragmented machine), not the rule.
- A TODO deleted, October. The comment asking for the 2 MiB window to scale with machine size was removed by Lorenzo Stoakes, because newcomers kept sending patches for it, most of them likely LLM-written. The window is still 512 pages.
CDN77's own fix was blunt: they moved nginx into the root cgroup, which vmpressure ignores. Their post ends with a promise of a proper fix later.
Check your own servers
None of this needs a reboot or a setting change; reading /sys and running ss is enough. I wrote these from the kernel docs and source on a Mac, with no Linux box to run them on, so treat them as a starting point.
Kernel version and cgroup mode (cgroup2fs means v2, where this path applies; cgroup v1 uses a different signal):
uname -r stat -fc %T /sys/fs/cgroup On 6.19 or newer, read the counter. It rolls up to parents, so the slice total covers every service under it:
grep sock_throttled /sys/fs/cgroup/system.slice/memory.events grep -H sock_throttled /sys/fs/cgroup/system.slice/*/memory.events If nginx.service has no memory.events of its own, its sockets are charged to the nearest parent that has one. The number counts throttle checks, not seconds, so it grows fast. Zero versus climbing is what matters.
On an older kernel there is no counter, but the fingerprint still works. ss -tin prints advmss and rcv_ssthresh for each connection, and this counts how many sit at exactly four times their MSS:
ss -tin | awk '{a=r=0; for(i=1;i<=NF;i++){split($i,f,":"); if(f[1]=="advmss")a=f[2]; if(f[1]=="rcv_ssthresh")r=f[2]} if(a&&r){n++; if(r==4*a)c++}} END{print c+0, "of", n+0, "sockets clamped to 4 x advmss"}' I tested that one-liner on sample ss output, not a live server. A few clamped sockets can be noise. A big share during a slowdown is the signal.
The ways out, and what each costs
- Run 7.2 or later if your trigger is high-order reclaim, as at Meta. It does nothing for plain reclaim that is just inefficient.
- Move the service to the root cgroup, as CDN77 did. That service loses its memory accounting and any limits.
- Boot with
cgroup.memory=nosocket, which rid suggested on HN. Socket buffers stop counting toward any cgroup's memory, and lokar replied that for a proxy that does not cache, that can be the largest thing the limit was there to catch.
The lesson I am keeping: when a service is slow and the same request from a shell is fast on the same box, compare cgroups before you compare configs. The sysctls, nstat and free memory were all telling the truth. They were looking at the machine, and the throttle was on the group.
Run the two grep lines on one of your Linux servers: is sock_throttled zero, and if it isn't, which service's cgroup is it climbing in?




