What is swap memory?

Mujkanovic

Well-known member
Collaborate
Registered
Joined
Apr 24, 2016
Messages
424
Points
18
Can you guys tell me what is swap memory? does it help increase RAM for my VPS or dedicated server? what are its main benefits?
 

hostens

Well-known member
Hosting Provider
Registered
Joined
Jan 18, 2017
Messages
215
Points
28
SWAP memory is usually half of your available RAM memory and is used by your server in those cases when almost all the available active RAM memory is used up. If active RAM memory is busy and you run out of free memory the server "puts" some of the running processes in the SWAP memory temporarily until active memory is freed up. This avoids server killing the processes when you run out of free memory. This is great when you need to keep the processes running, but you use up all the active memory not all the time.

SWAP memory is not the same as RAM memory and should not be considered as a replacement.

Some of the VPS packages allow increasing SWAP. Your hosting provider could answer if SWAP memory size can be increased or not.
 

VirtuBox

Well-known member
Registered
Joined
May 3, 2016
Messages
1,622
Points
83
Can you guys tell me what is swap memory? does it help increase RAM for my VPS or dedicated server? what are its main benefits?
SWAP memory is a secondary storage on disk. It was (and it's still) mostly used to avoid running out of memory. On linux, when your RAM usage is too high, if there is a SWAP partition on your disk, your operating system will automatically move some data on it. But the main issue is SWAP is very slow compared to RAM, even on SSD storage. That's why, it's better to avoid using too much SWAP for better performance.

The most part of VPS or public cloud instance do not have a SWAP partition, because it will not be possible to resize the server storage on the fly if there was SWAP.
But you can still configure a SWAP partition yourself :


Bash:
# Create a swap directory of 1GB 
dd if=/dev/zero of=/var/swap bs=1k count=1024k

#Prepare the directory /var/swap to use it as swap 
mkswap /var/swap 
swapon /var/swap 

# mount the swap partition
echo '/var/swap swap swap defaults 0 0' | sudo tee -a /etc/fstab
 
Newer Threads
Replies
1
Views
1,734
Replies
19
Views
6,999
Replies
5
Views
3,912
Latest Threads
Replies
1
Views
24
Replies
0
Views
179
Replies
1
Views
39
Replies
2
Views
81

Latest postsNew threads

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top