Quick Answer: TCP throttling in Linux can come from the cgroup memory controller, not from your network or your sysctl settings. When reclaim in a non-root cgroup frees less than about 40% of the pages it scans over a roughly 2 MB window, the kernel marks every TCP socket in that cgroup as under pressure for one second. Each socket's receive window then collapses. Check the sock_throttled counter in memory.events to confirm it.

Your download speeds drop for no visible reason. Error logs are clean, CPU and RAM look fine, and the tcp_rmem values match your healthy servers. Then, a few hours later, everything recovers on its own. That's the pattern CDN77 saw on its edge servers, and the cause was hiding in a place most engineers never check: the memory controller's socket pressure logic. Here's how they found it, and what you can do if you see the same symptoms.

Why the usual suspects came up empty

The CDN77 team, as described in their engineering write-up, started where most of us would. They checked ISP and peering paths, the tcp_rmem, tcp_wmem, and tcp_mem sysctls, proxy buffering in nginx, disk I/O, and kernel logs. Every candidate checked out. The problem also appeared in several regions, which ruled out a single bad network path.

One clue mattered more than the rest. The slowdown only hit cache misses, where the edge had to fetch content from an upper tier. Cache hits were fine. A curl run on the same box during an episode was fast, but nginx was slow. That pointed at something specific to nginx's own sockets, not the machine as a whole.

Tracing the problem into the kernel

Userspace looked clean. Nginx was issuing reads as fast as possible and draining until EAGAIN, so it wasn't stalling itself. The team then attached kprobes to tcp_rcv_established with bpftrace and printed fields from struct tcp_sock, including rcv_wnd, window_clamp, and rcv_ssthresh.

The receive window was the suspect, and rcv_ssthresh was the tell. It sat at exactly four times the advertised MSS. In the kernel, that value is only written by tcp_adjust_rcv_ssthresh(), and the only path to it ran through tcp_under_memory_pressure().

Here's where it got strange. The global counter said there was no memory pressure at all:

$ nstat -z | grep Pressure
TcpExtTCPMemoryPressures        0                  0.0
TcpExtTCPMemoryPressuresChrono  0                  0.0

So the function was returning true for a reason the global counter couldn't see.

The cgroup check nobody reads

Most engineers assume TCP memory pressure is a single global flag. It isn't. In the kernel, tcp_under_memory_pressure() also checks whether the socket's memory cgroup is under socket pressure, whenever the cgroup memory controller is enabled. On most distributions it is, by default.

static inline bool tcp_under_memory_pressure(const struct sock *sk)
{
    if (mem_cgroup_sockets_enabled && sk->sk_memcg &&
        mem_cgroup_under_socket_pressure(sk->sk_memcg))
        return true;

    return READ_ONCE(tcp_memory_pressure);
}

That's the piece that matters. The flag is set per cgroup, not per socket. One reclaim shortfall in a cgroup throttles every connection that cgroup owns.

Systemd makes this worse without asking. It places each service in its own cgroup and turns on the memory controller by default. The team wasn't using memory.high or memory.max, so they had no limits configured. The controller was still loaded, and loading it was enough.

What actually raises the pressure

The kernel's vmpressure() function is responsible for raising socket pressure. According to the source, it returns immediately for the root cgroup, so only non-root cgroups are affected. When the pressure level rises above VMPRESSURE_LOW, it sets memcg->socket_pressure to jiffies + HZ, which throttles every socket in that cgroup for at least one second.

Reclaim efficiency determines the level. Once about 2 MB of pages have been scanned, the kernel computes a ratio. If less than roughly 40% of the scanned pages were freed, the cgroup counts as under pressure. The formula doesn't consider how much free memory the machine has.

This is the counter-intuitive part. A cache-heavy server can have hundreds of gigabytes free and still trigger this throttle, because the check only looks at reclaim efficiency in one small window. In the kernel version the team debugged, the window was a hardcoded constant:

/*
* TODO: Make the window size depend on machine size, as we do for vmstat
* thresholds. Currently we set it to 512 pages (2MB for 4KB pages).
*/
static const unsigned long vmpressure_win = SWAP_CLUSTER_MAX * 16;

A cache-miss-heavy workload keeps the reclaim path busy, which is exactly the pattern that trips this check. That's why the bug only showed up on cache misses.

Diagnosing it on your own servers

You can check whether your services are exposed. Start by finding which cgroup your service runs in:

  1. Find the service's cgroup with systemctl show -p ControlGroup <unit>.
  2. Read memory.events for that cgroup under /sys/fs/cgroup/.
  3. On Linux 6.19 and later, look for the sock_throttled counter. A rising value means sockets in that cgroup were throttled.
  4. Compare against a healthy node running the same workload.

On older kernels there's no counter, so you'll need to correlate slowdowns with nstat output and bpftrace probes on tcp_under_memory_pressure(). That's slower, but it works.

Options, with trade-offs

The team tried a quick workaround: they moved the nginx processes into the root cgroup. vmpressure() skips the root cgroup, so socket throttling stopped. There were also no OOM kills, which suggests the throttle wasn't justified in the first place.

OptionEffect on socket throttlingTrade-off
Keep service in a non-root cgroup (default)Throttled on reclaim shortfallHidden slowdowns, no visible error
Move service to root cgroupNot throttled by vmpressure()Loses per-service memory accounting and limits
Set memory.high or memory.max on the serviceIntended for memory control, not a fix for thisCan trigger real reclaim and make the problem worse
Upgrade to a kernel with sock_throttledMakes the throttling visibleObservability only, not a fix

The root-cgroup move is a workaround, not a fix. You give up per-service memory accounting, and the source says a proper fix is still coming. Treat it as a stopgap until you can test the upstream change on your kernel.

Where most guides go wrong

Most troubleshooting guides send you to tcp_rmem and the network path first. That's sensible, but it misses this case entirely. The sysctls were identical on healthy and broken servers, and that should have been the clue. When the config is the same and the behaviour differs, look at what changes at runtime, such as memory pressure, reclaim, and cgroup state.

That said, there's a real caveat. Not every slow download is cgroup throttling. Confirm the sock_throttled count or the rcv_ssthresh symptom before you change anything. The source's 40% threshold and 2 MB window describe one kernel version, and the constants may differ on yours.

Frequently Asked Questions

what is TCP throttling in Linux?

TCP throttling in Linux is when the kernel shrinks a socket's receive window, usually rcv_ssthresh, which caps how fast data can arrive. It can happen because of global TCP memory pressure or, as CDN77 found, because of memory cgroup socket pressure. The connection stays open, but throughput drops sharply until the pressure clears.

how to check if TCP throttling is happening on my server?

Read memory.events for your service's cgroup and look for the sock_throttled counter, available on Linux 6.19 and later. On older kernels, use nstat -z | grep Pressure for global pressure, and bpftrace probes on tcp_under_memory_pressure() for cgroup pressure. A healthy server should show zero or stable counts.

why does nginx download slowly on cache misses but not cache hits?

Cache misses force the server to fetch and reclaim memory while it streams data, which keeps the reclaim path busy. That can push the cgroup's reclaim efficiency below the threshold in its roughly 2 MB scan window. Cache hits don't drive the same reclaim activity, so their sockets usually stay unthrottled.

can I fix TCP throttling by changing tcp_rmem or tcp_wmem?

Usually not. In the CDN77 case, the tcp_rmem, tcp_wmem, and tcp_mem values matched healthy servers, and the throttle came from the memory cgroup, not the TCP sysctls. Check cgroup pressure first. Changing the sysctls without evidence is guesswork.

Stop guessing and check the cgroup

If your downloads slow down for hours and then recover on their own, check memory.events for sock_throttled on the service's cgroup before you touch anything else. Try reading that counter on one of your edge or proxy nodes this week and note whether it moves during a slowdown. That single check can save you days of chasing ISPs and sysctls.