16GB RAM and 4GB swap

Hello all!

Is this setup correct? Asking as my system has quite a lot ram as per home server and has not much to do. It's mainly NFS + jail to learn. Most of the time, I see 14G of ram is free.

Many sources says that I should have at least the same amount swap as I have ram but it doensn't make sense in my case, unless there's a reason behind. Shall I break my setup and assign 16GB swap?
 
I don't know if that's of any help but here's my swap assignment almost every time I build a home/work system -
> Swap space == RAM (if RAM < 8GB)
> Swap space == 0.5 times RAM (if RAM > 8GB)

(Also what kind of applications will run on system and usage matters here)

No actual logic behind it, its been working fine for me so far. Memory management is smart these days for Linux and BSDs both.

Regards.
 
That seems fine on a home server.
Would be different on a test system ( heavy compiling ) or something that is working hard.
 
Year ago I had older machine with 4 RAM and I've seen system using swap (also 4GB). Here it didn't happen.

I will stay with 16/4 than. Thank you!
 
It would work perfectly fine without any swap for most of the time. In the rare event the system goes low on memory you want to have some swap so that your system doesn't crash. In some other systems (UNIX systems of '80s and´90s mostly) it was mandatory to have at least the amount of physical memory as swap because the virtual memory was implemented differently and unfortunately some people still keep repeating this erroneously as something that would apply to Linux and FreeBSD as well.
 
There is no magic formula any more. For example, I have a production server with 4GB of RAM and 4GB of Swap. Swap is rarely used... Last night an application that makes SQL operations hit a bug and as a result all Swap was consumed.
Code:
kernel: swap_pager_getswapspace(3): failed
Still, the other services were working although it was very slow. If I had 8GB of Swap then they would have been consumed as well with the same result.
 
Yes, it comes down to: If you really need swap, you already have a problem. Swapping is extremely slow. You want to have some swap space in order to keep the system running if you ever hit the physical memory limit, but this should be a rare and extraordinary condition. For this, 4G should be enough nowadays, no matter how much physical memory you have installed.
 
Back
Top