What is swap memory?

Mujkanovic

Well-known member
Joined
Apr 24, 2016
Messages
196
Best answers
1
Ratings
4
Points
18
#1
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
Joined
Jan 18, 2017
Messages
160
Best answers
2
Ratings
55 6
Points
28
#2
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

Global Mod
Staff Member
Joined
May 3, 2016
Messages
1,501
Best answers
4
Ratings
381 10
Points
83
#3
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
28
Replies
1
Views
42
Latest Threads
  • Deleted
  • Deleted by Localnode
Replies
0
Views
9
Replies
1
Views
9
Recommended Threads
Replies
1
Views
1,756
fwh
Replies
16
Views
1,691
Replies
1
Views
56
Replies
6
Views
1,529

Latest Hosting OffersNew Reviews

Sponsors

Latest Blog ArticlesMost Viewed Threads

Top