hn.today

Uncovering Hidden TCP Throttling in the Linux Kernel

cdn77.com407 points49 comments
Screenshot of Uncovering Hidden TCP Throttling in the Linux Kernel

CDN77 engineers investigated intermittent download slowdowns affecting some nginx cache-miss connections. Speeds could remain low for hours and recover without intervention; direct curl tests, other services, and neighboring servers were unaffected, while rebooting temporarily cleared the problem. Network paths, TCP settings, nginx configuration, system resources, and read/epoll behavior showed no cause. Kernel tracing instead revealed that affected TCP sockets had an unusually small receive-window threshold: four times the advertised maximum segment size. That value was being set when the kernel considered the socket under memory pressure, despite system-wide TCP pressure counters reporting none.

The hidden trigger was memory pressure recorded for nginx’s systemd cgroup. Linux checks both global TCP pressure and a socket’s cgroup pressure, and a reclaim shortfall can set a cgroup-wide flag that reduces the receive buffers of all its sockets. The flag can be raised when reclaim frees less than roughly 40 percent of pages scanned in a small, fixed two-megabyte window - not when the machine is actually short of free RAM. Cache-heavy workloads could therefore throttle nginx connections despite abundant memory. Moving nginx into the root cgroup stopped the effect because root cgroups do not receive this pressure signal. CDN77 also contributed a Linux change: since kernel 6.19, memory.events includes a sock_throttled counter to expose sockets throttled by this mechanism.

Read on cdn77.com49 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

Laravel Go

Laravel Go

Laravel for Go is a full-stack web framework with routing, validation, database tools, background jobs, workflows, and real-time events. It also supports Inertia for frontend integration and is open source under the MIT license. (github.com)

Laravel Go

Laravel Go

Laravel Go is a batteries-included Go framework that combines routing, data access, authentication, queues, workflows, and other features in one package. It uses standard Go patterns and Inertia to serve React, Vue, or Svelte pages without separate API boilerplate. (laravel.com)

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.