Should I use swap in KVM guest?
Now I'm trying to create KVM templates with CentOS and I'm not sure should I create swap partition on guest OS or not. In future it will be lot's of small VPS with 256-1024Mb RAM and if swap partition is a good idea will be 256Mb of swap enough for making them more stable?
Solution 1:
Sure. Go for it... Those sound like low-memory virtual machines. It may be helpful to have swap in place in the event memory is exhausted. If not, you can always add swap files later.
Solution 2:
One other thing to consider... some applications, databases most notably, try to consume all the physical RAM they can. Unfortunately, if your database is large enough, your database server will take your server to the brink of no memory. If things get to constrained, the kernel will pull out its pistol and start shooting processes in the head to recover memory. In my experience, it seems the RAM munching database is the first go.
Add a little swap.