
Content delivery networks are notoriously complex and finicky systems. So no one at CDN77 was terribly surprised when customers started complaining about degraded performance on their edge servers. For a few hours they would notice slower speeds, than, the bug would self-heal and normal speeds would return. But that simple complaint led down the rode to patching a bug in the Linux kernel.
In a sense, CDN77’s edge network consists of a large number of high-memory CPU servers geographically dispersed serving nginx with a bit of magic. These are used a the last point in a chain of proxies to serve content like videos to the end-user. The usual suspects could be eliminated early on in the process. The issue was geographically disperse, eliminating ISP issues. The servers were also identically configured. Even the CPU utilization returned normal, with no reported memory pressure.
What proved even stranger is that only nginx was effected by the bug, and it only appeared on HTTP cache misses. However, nginx appeared run as expected; no delays in syscalls or other anomalies. Finally, in the Linux kernel TCP stack, a pattern begun to emerge. The kernel was clamping the window to a quarter its maximum, a feature designed to prevent network congestion. The kernel thought there was significant pressure on the TCP stack and begun throttling connections, a strange behavior given no overall system memory pressure.
Eventually, CDN77 found that the TCP memory pressure check doesn’t solely depend on system memory utilization, but also cgroup memory utilization. Systemd launched its services in their own cgroup, which provides additional memory utilization features. If less than 40% of a cgroups memory can be reclaimed, it triggers the cgroup’s TCP memory pressure, and throttles all its connections. This process fails to take into account the amount of memory free on the machine. A TODO all the way back from 2013 suggests taking into account the total machine memory, and since Linux 6.19, this has been fixed.
If you are using an older version of Linux and find yourself with this bug there is a quick fix. TCP connects are only throttled in non-root cgroups, so you can simply move the process to the root cgroup! In the off chance you aren’t administering a complex CDN network, it was a really fun look at the debugging process of such a complex network. Understanding bugs in edge cases can provide us with better tools to understand the diaspora of bugs that pop up in our day to day.
This articles is written by : Fady Askharoun Samy Askharoun
All Rights Reserved to Amznusa www.amznusa.com
Why Amznusa?
AMZNUSA is a dynamic website that focuses on three primary categories: Technology, e-commerce and cryptocurrency news. It provides users with the latest updates and insights into online retail trends and the rapidly evolving world of digital currencies, helping visitors stay informed about both markets.
