"How much swap should I have" is one of those questions that has been answered a thousand times and still starts arguments, because the honest answer is "it depends" and nobody likes that answer. So here is my settled position for my own homelab, which is the only context I can actually speak to with any authority.
I keep a small amount of swap on every box, even the ones with plenty of RAM. Not because I expect to run out of memory, but because of what the kernel does when there's no swap at all. A Linux box without swap doesn't gracefully slow down when memory gets tight. It hits a wall and the OOM killer starts shooting processes. With a little swap, the kernel has somewhere to push pages that genuinely aren't being touched, which buys you headroom and, crucially, a warning. You see swap usage creep up and you have time to react before something gets killed at three in the morning.
The old "twice your RAM" rule is long dead and you can ignore it. It made sense when machines had 256MB of RAM and you wanted room to hibernate. On a server with 16 or 32 gigs, twice that in swap is just wasted disk that, if you ever actually used all of it, would have your machine thrashing so hard it might as well be off. My rule of thumb for a homelab box is a couple of gigabytes, flat, regardless of RAM size. Enough to absorb cold pages and give a warning, not so much that the box can limp along in a swap-thrashing coma pretending to be alive.
The setting that actually changes behaviour is vm.swappiness. It controls how eagerly the kernel reaches for swap versus reclaiming page cache. The default of 60 is tuned for desktops and is far too keen for a server, where I'd rather keep my working set in RAM and only swap when there's genuine pressure. I set it low:
# /etc/sysctl.d/99-swap.conf
vm.swappiness = 10
Ten, not zero. Zero tells the kernel to avoid swap almost entirely, which sounds clever but pushes you back towards the OOM-killer cliff edge the swap was there to prevent. Ten says "use it, but only when you really need to", which is exactly the behaviour I want. Apply it with sysctl --system and check with cat /proc/sys/vm/swappiness.
One genuine exception, and it's worth calling out: anything running a database with strict latency expectations, or certain clustered systems, will tell you to disable swap entirely, and they have good reasons. A spike of latency from a page fault into swap can be worse for them than a clean failure. I respect that, and on the one box where it applies I follow the vendor's advice rather than my own rule of thumb. The rule of thumb is for the general case, not for every case.
For everything else in the cupboard, the answer is the same: a small swap partition or file, swappiness at 10, and move on. It's not the heroic answer the internet wants, but it's the one that has kept my boxes from waking me up. Settled, at least until someone gives me a reason to change my mind, which they inevitably will.