A box that was mostly happy had one annoying habit: every so often everything would freeze for a second or two, then carry on as if nothing had happened. No CPU spike worth mentioning, no obvious culprit in the logs. The giveaway was that it always coincided with a burst of disk activity. The kernel had been quietly hoarding dirty pages in memory and then trying to flush all of them at once.
The two knobs that matter live in /proc/sys/vm. dirty_ratio is the hard ceiling: once that percentage of memory is full of dirty pages, writing processes are blocked until the flush catches up, which is exactly the stall I was seeing. dirty_background_ratio is the gentler one: cross that and the kernel starts flushing in the background without blocking anyone.
On a machine with a lot of RAM, the defaults let a frankly enormous amount of dirty data pile up before anything starts writing it out. When the ceiling finally hits, you get a thundering flush and a visible pause. The fix is to flush earlier and more often, in smaller amounts:
vm.dirty_background_ratio = 5
vm.dirty_ratio = 10
Drop those into /etc/sysctl.d/ and apply with sysctl --system. The background flush now kicks in much sooner, so writes trickle out steadily instead of building up for one big dramatic gulp. The stalls vanished. Throughput on sustained writes is fractionally lower, which I have never once noticed, in exchange for the box staying responsive instead of holding its breath. For an interactive machine that is the right trade every time.