I have occasionally heard students in my training classes mention that they configure their servers with no swap space. The students have two reasons for this:
- I have enough memory so I shouldn't be swapping
- I don't want to swap because it is slow
Both of these reasons are inaccurate. Let's look at the first one, "I have enough memory so I shouldn't be swapping". While it is generally true that large memory systems never fully use their RAM, it isn't optimal to avoid swap. Applications often have initialization code that can be written to swap so the memory can be used for other purposes. Kernel kernel hacker Andrew Morton once stated:
My point is that decreasing the tendency of the kernel to swap stuff out is wrong. You really don't want hundreds of megabytes of BloatyApp's untouched memory floating about in the machine. Get it out on the disk, use the memory for something useful.