Do we really need swap on modern systems?

 Swap is used to give processes room, even when the physical RAM of the system is already used up. In the past, some application vendors recommended swap of a size equal to the RAM, or even twice the RAM. Once the physical memory is used up, swap gets used. As the swap disk is much slower than RAM, the performance goes down, and thrashing occurs.

A typical reference to RAM is in the area of 100ns, accessing data on a SSD 150μs (so 1500 times of the RAM) and accessing data on a rotating disk 10ms (so 100.000 times the RAM).

With no swap configured as the system runs out of RAM, it has no swap to hand out. There is almost no time frame of reduced performance – the OOM kicks in immediately.

This article gives size recommendation for most modern Red Hat Linux systems ‘a part of the physical RAM’, for example, 20%. With this, the painfully slow phase of operation will not last as long, and the OOM kicks in earlier. Of course, there are scenarios when different behaviour is desired. Systems without swap can make sense.


Be the first to post a comment.

Leave a Comment

Your email address will not be published. Required fields are marked *