Should swap always be enabled?

Should swap always be enabled?

The short answer is, No. There are performance benefits when swap space is enabled, even when you have more than enough ram. Update, also see Part 2: Linux Performance: Almost Always Add Swap (ZRAM). Now, let’s look at how swap space can actually help Linux server performance.

Is too much swap space bad?

Conclusion. Hence, one drawback of having too much swap space is: the more you have, the later this OOM situation occurs and the longer you will have to suffer from a lagging and unresponsive system. Another apparent downside of course is wasting disk space but that might not be so important nowadays.

What is the recommended swap size?

What is the right amount of swap space?

Amount of system RAM Recommended swap space
less than 2 GB 2 times the amount of RAM
2 GB – 8 GB Equal to the amount of RAM
8 GB – 64 GB 0.5 times the amount of RAM
more than 64 GB workload dependent

How do I choose swap size?

How much should be the swap size?

  1. If RAM is less than 1 GB, swap size should be at least the size of RAM and at most double the size of RAM.
  2. If RAM is more than 1 GB, swap size should be at least equal to the square root of the RAM size and at most double the size of RAM.

How can I reduce the size of swap?

For traditional hard drives, moving swap closer to the center of the physical disk may help, as seek times are generally shorter at the center due to less travel of the drive heads. Having swap on an SSD can help significantly as well, but I’d caution you that this may create a lot of wear and tear on a SSD, and will give it a shorter lifespan.

How big of a swap do I Need?

This is still good advice, but in practice more modern systems with 4GB or more of physical ram can usually drop this to the same amount of swap as the system has of physical memory. There are a few things you can do to improve performance when using swap.

What are the advantages and disadvantages of swapping?

Another advantage is that swap gives admins time to react to low memory issues. We will often notice the server acting slowly and, upon login, will notice heavy swapping. Without swap (as described in the next section), running out of memory can create much more sudden and severe chain reactions.

Is it worth it to use swap space?

The short answer is, No. There are performance benefits when swap is enabled, even when you have more than enough ram. With more than adequate server memory installed, you will often find that after long periods of uptime, swap space will be used.