5 comments

  • freedomben 1 hour ago
    More 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.
  • rid 10 minutes ago
    I 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).
  • montjoy 1 hour ago
    Lots 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 controllers

    Thank you for sharing.

  • dedalus 49 minutes ago
    We 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
  • jeffbee 1 hour ago
    One 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.
    • mk12 13 minutes ago
      The dirty ratio also behaves differently than I assumed at first. 20% does not mean 20% of all memory, it means 20% of "dirtyable" memory. Also, 1GB dirty threshold does not mean that writes only get slowed down at 1GB. There is a "freerun" threshold at the midpoint between the background dirty limit and the dirty limit, and the kernel starts progressively throttling writers at that midpoint.
    • the8472 59 minutes ago
      depends, if you have servers that buffer large blobs in tempfiles you don't really want those flushed to storage unless there's a real memory shortage.
      • hosteur 15 minutes ago
        But is that a default usecase?
      • jeffbee 19 minutes ago
        No, on a multi-tenant machine I really, really want that tempfile thing to be throttled on dirty page creation. If that process thinks it can run in constant space without externalizing the page cache then it knows what to do: write its temporary objects to anonymous memory, not files.
    • tremon 9 minutes ago
      The volume of the writeout in itself would not be a problem if it weren't that the dirty page table is locked until writeout completes. That means that new page allocations are stalled while writeout is in progress. And you're right, the default dirty page ratio is way too high, especially in the much-ram-meets-spinning-rust scenario. I have had rsync backups stall for over a minute while the archive server digests its dirty page buffer, only to have the server then stop writing for long enough to allow the disks to go back to standby mode.

      It would take major engineering effort in the VFS layer to avoid locking the page table during writeout, but that's what a proper solution would look like in my eyes.