Does it matter about the amount of the swap area in Linux system

Does it matter if the amount of a swap area in Linux was set too small (say 1Gb), and the main RAM is 128Gb?

Should we always set the amount of swap area to be twice the amount of RAM?

UPDATED:

Hi, thank all of you for replying this question. In fact, I have this question because we have encountered some problems when using a small cluster system. The problems are posted in Here. The following picture is some information about some of the computers in this small cluster.

information

The MEMTOT is the total amount of RAM of that machine, the SWAPTO is the total amount of SW AP area of that machine, and the SWAPUS is the used amount of SWAP area. As shown in the picture, the usage of SWAP is indeed small.

When trying to solve those problems posted in Here, we're not sure if the amount of SWAP area is set too small, which is just 1Gb relative to 128Gb, as shown in the picture. Thus, I have this question. I'm sorry I didn't post the whole background information in the original version of this post. Before that, we also thought that if the amount of RAM is large, we could set the amount of SWAP small. We tried to set the SWAP of c0148 to be 16Gb, the problem seems to be none (Maybe we should take this conclusion after observing their statuses for a long time).

We're not professionals on Linux system, and we couldn't explain why this happened. It is a probability that this is a cluster system, and the SGE is managing the resources of each machine, and it needs to have a relative large amount of SWAP because that machine may be used by many jobs submitted by many users.

In addition, if we just set the amount of SWAP too large, what other problems it would cause is also worthy considering.


The Linux kernel has a setting to control how often the swap is used, called swappiness, described at https://unix.stackexchange.com/questions/88693/why-is-swappiness-set-to-60-by-default.

A swappiness of zero means that the swap will be used only if the system runs out of memory. A swappiness of 100 forces programs to use swap instantly.

Tweak your system as you like it to behave, but having 128 GB of RAM is very unlikely that your system runs out of memory easily, so having 2 / 4 GB of swap could be enough. It's not advisable, but possible, to run a system without swap partition.

I think the rule of the swap area to be twice the amount of RAM is outdated, and is useful only on systems that are around 1 GB of RAM and are always on the edge of full RAM usage.


I believe the 2x rule of thumb is outdated. Our workstations have 16GB ram, we typically only use around 25% of that and hardly use over 50%. So for our purposes, we don't use any swap.

Since you have to decide how much swap to create, and it's theoretical that any number you choose will not be enough at some point, then why not choose 0? Or - why not just install more RAM?

I believe this is a very personal decision based on how your computer will be used and how much RAM it has.