Portal Home > Knowledgebase > Articles Database > Swap in VPS


Swap in VPS




Posted by fastwebhost, 09-16-2016, 04:10 AM
I have heard about overselling RAM, but have never heard about overselling swap. So i'd like to ask whether such thing exists? When i purchase VPS, they give me some amount of swap. Is this swap one part of the big swap file in the dedicated server (node)? I found some provider quite stingy about swap amount, not sure why, but i though swap is simply a portion on the hard disk, why don't they just create and give customers a bigger amount of swap to make customer happy? Or having bigger swap reduces the node performance? Hope someone can clear my mind about this.

Posted by Maple-Hosting, 09-16-2016, 09:00 AM
Using swap reduces performance of the VPS using it. Swap is basically emergency memory and is used only when you have to use it. Why would providers give more swap? If you're using it you're going to get bad performance on your VPS. You would generally not want much because you need RAM and not swap.

Posted by finder87, 09-16-2016, 10:41 AM
Since with KVM and others full virtualization platforms you can create swap space yourself, probably you are talking about OpenVZ vSwap. vSwap is an actual RAM on the host (well unless the host is out of RAM, then it is a part of a host swap), so it is totally understandable why it is limited.

Posted by Layershift Damien, 09-17-2016, 04:51 AM
There are 2 main reasons why swap matters to a VPS provider: 1. Disk is a shared resource, which includes disk I/O too. If you're thrashing disk I/O with heavy swapping it can quite likely become a noisy neighbour for others. 2. Obviously they prefer to sell you more RAM (if that's what you need). Neither of these points are secrets or disadvantages for end users. As was already mentioned, swap is fine for emergencies but servers should have plenty of RAM and only a small amount of swap.

Posted by vps_newbie, 09-17-2016, 01:21 PM
KVM: A KVM virtual machine has its own swap because it is a complete virtualized hardware system. RAM can be oversold in KVM, but it is less common and slightly more difficult for the provider to do. OpenVZ: When I signed up for my first OpenVZ VPS a few years ago, it came with a certain amount of "burstable RAM", which was additional RAM memory as a shared resource between all of the VPSs on that node. If your VPS consumed all of its guaranteed RAM, then a memory request might be fulfilled using the burstable RAM, assuming that some was available. Your software had to be ready to deal with the situation that the memory request would be declined because the other nodes had consumed all of the burstable RAM. It came with no guarantee. Soon after, OpenVZ began offering "vSwap". As I understand it, vSwap is an improvement over burstable RAM because the vSwap is "guaranteed" in the sense that the memory request will not fail, although it may not yield the desired performance. These days, OpenVZ VPSs offer vSwap. CAVEAT: I cannot promise that the above is absolutely correct, but that is how I understood it at the time. I hope this helps, or at least points you in the right direction.

Posted by fastwebhost, 09-18-2016, 09:24 PM
Thank you all for very nice explanation, so from what i understand, swap/vswap in KVM and OpenVZ has nothing related to the swap of the node, as long as the node has RAM that is more than the total RAM+swap/vsap of all VPS (as well as the RAM needed to run the host itself, ofcourse). Is it right?

Posted by BrianHarrison, 09-18-2016, 09:47 PM
Incorrect -- with OpenVZ the node has a single swap in which all VMs may contribute too. With KVM, the virtualization is more isolated and each VM has dedicated memory allocations -- the swap for each VM is independent of the other VMs on the node.

Posted by fastwebhost, 09-18-2016, 09:51 PM
So, do you mean the swap inside each VM are not only from real RAM of the node, but also from the swap of the node (if the node runs out of RAM)? If yes, then what i concluded earlier should be correct, right? Thanks!

Posted by LinuxFox, 09-18-2016, 10:05 PM
In any case you should not select a provider based on SWAP offerings. It is not something to be used regularly or intentionally. Keep in mind that swapping on a particular VPS would lead to performance degradation of all other virtual servers hosted on the same node including yours!

Posted by net, 09-19-2016, 01:41 AM
No, it is not. It is being used on your allocated data ( at least for KVM ).



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
Nginx vs Lighttpd (Views: 610)