修复 Linux 中的内存漏洞,让网络传输更快Fixing a Memory Bug in Linux, for Faster Networking


AI free token/AI免费积分

修复 Linux 中的内存错误,实现更快的网络 3 条评论 作者:Fenix Guthrie 2026 年 12 月 5 日 标题:复制短链接:复制 内容交付网络是出了名的复杂和挑剔的系统。

因此,当客户开始抱怨其边缘服务器性能下降时,CDN77 的任何人都不会感到非常惊讶。

在几个小时内,他们会注意到速度较慢,错误会自我修复,并且会恢复正常速度。

但这个简单的抱怨导致了从某种意义上说,CDN77 的边缘网络由大量地理上分散的高内存 CPU 服务器组成,为 nginx 提供了一些神奇的服务。

这些被用作代理链中的最后一个点,向结果用户提供视频等内容。

在此过程的早期可以消除常见的嫌疑人。

该问题在地理上分散,消除了 ISP 问题。

服务器的配置也相同。

甚至 CPU 利用率也恢复正常,没有报告内存压力。

更奇怪的是,只有 nginx 受到该错误的影响,并且只出现在 HTTP 缓存未命中的情况下。

但是,nginx 似乎按预期运行;

没有延迟系统调用或其他异常。

最后,在 Linux 内核 TCP 堆栈中,一种模式开始出现。

内核将窗口限制到其较大值的四分之一,这是一项旨在防止网络拥塞的功能。

内核认为 TCP 堆栈上存在巨大压力,并开始限制连接,在没有整体系统内存压力的情况下,这是一种奇怪的行为。

结果,CDN77 发现 TCP 内存压力检查不仅取决于系统内存利用率,还取决于 cgroup 内存利用率。

Systemd 在自己的 cgroup 中启动了其服务,这提供了额外的内存利用率功能。

如果 cgroups 内存低于 40%,则可以回收后,它会触发 cgroup 的 TCP 内存压力,并限制其所有连接。

此过程未能考虑计算机上的可用内存量。

自 2013 年以来,TODO 建议考虑计算机总内存,自 Linux 6.

19 起,此问题已得到修复。

如果您使用的是较旧版本的 Linux 并发现自己遇到此错误,则可以快速修复。

TCP 连接仅在非根 cgroup 中受到限制,因此您只需将进程移动到根 cgroup 即可!

如果您不管理复杂的 CDN 网络,则它对如此复杂网络的调试过程进行了一次非常有趣的观察。

了解边缘情况中的错误可以为我们提供更好的工具来了解日常生活中出现的错误的散布情况。

张贴在 网络黑客 标记 cdn , 调试 , 调试地狱 , linux hack , nginx , TCP , tcp/ip

修复 Linux 中的内存漏洞,让网络传输更快

本文来源:https://hackaday.com/2026/12/05/fixing-a-memory-bug-in-linux-for-faster-networking/
若有版权问题,请来信告知:13951431913#139.com 或在右方提交评论。

Fixing a Memory Bug in Linux, for Faster Networking

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.

本文来源:https://hackaday.com/2026/12/05/fixing-a-memory-bug-in-linux-for-faster-networking/
若有版权问题,请来信告知:13951431913#139.com 或在右方提交评论。

暂无评论,快来发表第一条评论吧!No comments yet. Be the first!

📮 需求咨询📮 Inquiry