<- Back
Comments (27)
- freedombenMore of a meta comment, but I'm always grateful for these sort of network-related debugging blog posts. As a software eng who has a good grasp of networking at a conceptual layer, but has struggled to translate concept into concrete implementation in linux, I get a lot of value from these. Thank you to the author(s) for putting in the effort to write this up.
- basilikum> Memory reclaim reports how many pages it scanned and how many it managed to free per cgroup. Once roughly two megabytes' worth of pages have been scanned, the kernel turns that into a ratio. If it freed less than about 40% of what it walked, that counts as memory pressure, and every socket in the cgroup gets throttled for that one second. What's NOT in the formula is how much free memory the machine has.Maybe I'm missing something, but can someone explain why memory pressure is detected like this in the first place? The article goes on to say that there was a TODO comment in the source to scale the scanning window proportional to the memory size, but why is memory pressure even measured like this without considering the free memory at all? Am I missing something or does that indeed make no sense?
- ridI think the workaround for this at the moment is the boot parameter: cgroup.memory=nosocket If you're not bothered about socket memory counting towards the cgroup's limit (it's usually negligible).
- montjoyLots of little gems in this article. e.g.> We launch nginx as a systemd service, and systemd places each service into its own cgroup and sets default controllersThank you for sharing.
- dedalusWe should have a target rate test on prod to ensure we always hit that and assert in logs when it goes slow (in this case its memory throttle tomorrow is something else) as to ensure consistent performance for our apps
- tonymetDo you need systemd or cgroups for this? Seems like unnecessary configuration and complexity.great effort debugging and isolating the root cause, but also an unnecessary issue.
- eikenberry> The two-megabyte window was a hardcoded constant in the kernel version we were debugging, with a TODO: in the kernel asking it to scale with the machine size.That TODO was removed about a month ago but remains there in spirit.https://github.com/torvalds/linux/commit/0041eef981cc55bb1f3...
- kalak> Disclaimer: No AI was used for writing this blog. Enjoy a humanly engineered piece.The disclaimer now belongs on articles that were human written?
- jeffbeeOne of the wrongest default parameters in Linux is the dirty page ratio. By default, if I recall correctly, it permits up to 20% of pages to be dirty. If you're doing some quick arithmetic you already see the problem. The whole "pressure stall" concept has been adopted to hide this fact, when the better option is to simply lower the dirty page limit (not ratio) to 1GiB or less.
- johnnyenn[dead]
- Beyen[dead]