Small Cheese

New Formula To Calculate Linux Swap Partition Size

Old school recommends the Linux swap partition should be at least 1.5 to 2 times of total memory installed. You might have no question to apply this formula on an aging server with probably only 2GB of RAM or much lesser.

But nowadays the new servers are easily built with few tens to hundreds of RAM and that means a lot of disk space will have to be allocated for swap partition if you have to apply the old formula.

So, what is the new school suggestion? Well, there is a reference of recommended swap space size made for installing RHEL 5.4 on x86/64 platform. The RHEL engineers seem have found the relationship between memory workload and swap space utilization.

However, it is not easy in practical to precisely determine memory workload before the server is installed with OS and deployed to production. Thus, they suggest a reference of recommended swap space size as follow:

At least
  • 2GB swap space for 4GB of RAM or less.
  • 4GB swap space for 4-16GB of RAM
  • 8GB swap space for 16-64GB of RAM
  • 16GB swap space for 64-256GB of RAM
  • 32GB swap space for 256-512GB of RAM

If there is more than 1 disk drive installed in the server, you should also try to allocate the swap space to multiple disk disks for better overall performance.

If there is no dedicated recommendation made for your Linux distribution, then this reference is good for a guide. For those who are using CentOS, guess you know there is no difference between the two distributions.

Custom Search