

Even if there is still available RAM, the Linux Kernel will move memory pages that are hardly ever used into swap space. It’s designed to be complementary to the performance of healthy systems. Swap does not change the amount of RAM required for a healthy server, or desktop for that matter. However, this is hardly the case on servers, and you should instead balance your decision with the effects swap will have on your specific applications. If you can come up with valid reasons for this, then that maybe your choice. Some recommend no swap or swap size slightly larger than the total RAM.

It can even be smaller, especially if you have monitoring and/or alerting in place. For example, MySQL’s configured memory in my.cnf.

So usually, I would advise setting swap space to about the size of your largest process. Without swap (as described in the next section), running out of memory can create much more sudden and severe chain reactions. We will often notice the server acting slowly and, upon login, will notice heavy swapping. Swap usage becomes a performance problem when the Kernel is pressured to continuously move memory pages in and out of memory and swap space.Īnother advantage is that swap gives admins time to react to low memory issues. The Linux Kernel will move memory pages that are hardly ever used into swap space to ensure that even more cachable space is made available in-memory for more frequently used memory pages (a page is a piece of memory). It is normal and can be a good thing for Linux systems to use some swap, even if there is still available RAM. It now comes with ZRAM enabled by default.Īdvantages of swap space on systems with adequate RAM Update: Recently, I installed Manjoro i3 on my Pinebook Pro. Now, let’s look at how swap space can actually help Linux server performance. …so in this case, as in many, swap usage is not hurting Linux server performance. To confirm, I used the following command: ps -A | grep kswap In fact, the kswap process was nowhere to be found in top (top processes sorted by CPU time). Also, the kswap service didn’t consume much CPU time. When I ran checks for swapping, there were no signs of ongoing or untimely swap I/O activity. The output of free -h here shows 308M of swap space used. See the below example from a live-chat server with around one month of uptime: total used free shared buff/cache available Even with more than adequate server memory installed, you will often find that swap space will be used after long periods of uptime.
