unpopular opinion: disabling swap on your VPS is cargo cult advice

bananapeel42

New Member
Messages
53
Reaction score
0
Location
Manchester, UK

Every time someone posts a "my VPS is slow" thread, the first reply is always "do you have swap off?" and it gets upvoted like scripture. I don't get it.

I run a 2GB box, Alma 9, MySQL plus a couple of PHP sites. For two years I had swap disabled because everyone said so. Then I actually read the OOM killer logs and realized MySQL was getting murdered at ~1.9GB RSS while 300MB of swap sat there completely unused. Turned swap back on with swappiness=10 and the box has been boring ever since. Boring is the goal here.

The thing people miss is that swap isn't a performance switch, it's a safety net. If your working set genuinely fits in RAM, a bit of swap does nothing at all. If it doesn't fit, you get to choose between slightly slow and stone dead. I know which one I pick at 3am.

Now, swap on a spinning disk with a heavy DB workload? Yeah, that's actually bad, no argument. But we're all on NVMe now, and if you're paging hard enough to feel it, swap isn't your problem, your RAM sizing is.

Curious what swappiness numbers people actually run. I've seen everything from 1 to 60 and tbh nobody agrees on anything.

You must log in or register to reply here.