SWAP memory

Admins,

How can I configure the server so that it will utilize the swap file as little as possible? Please correct me if I'm wrong, I would say change the value of sysctl - vm.swappiness? And if, how can I keep it permenatly even after rebooting the system? since no related parameters in /etc/sysctl.conf?

You can add a line to /etc/sysctl.conf, for example

vm.swappiness=0
1 Like

I wouldn't go zero. That would disable swapping entirely:

Swappiness - Wikipedia, the free encyclopedia

1 Like

My box living with another VMs in the same host, so I don't want my box swap the others!

Swapping won't happen if you have more than enough ram. If swapping becomes necessary, and you have no swap, your system will stall terribly. If all else fails, you might consider a separate/private swap partition for your own VM?

Even on a cloud server level?

Oh. :slight_smile:
Ya got me there.

Then don't use any RAM on your VM. Kinda hard to do, but preventing other VMs from swapping is related to how much RAM you actively use.

RAM use is what forces other things in memory to be swapped out. The swap device is merely the persistent storage where the OS copies contents of physical memory that is needed by something else.

How much swapping is happening on the physical server is something the admins of that server have to deal with. Depending on how many VMs are hosted on the physical server, the swapping caused by your one machine might be about as significant as tossing rocks into the ocean during a storm. Yeah, your rocks still make waves but you can't even seem them.

Any system running as a VM that uses enough resources to starve out other VMs on the same physical host should IMO not be running as a VM - it needs it's own physical host. Even if you're virtualizing such a system for reliability - so you can migrate it in case of a hardware failure - you still need to keep enough physical server resources in reserve to account for that. In that case, run a physical active-active cluster and get better performance when running normally and probably much faster if not totally transparent failover in a failure scenario.

And if you're just outsourcing the physical hardware admin by using "the cloud" and getting pushback from your cloud provider for using too much resources, that's a contract issue between you and your cloud provider.

"The cloud" is pretty much just mainframe-computer era timesharing. It's "run and save my stuff on another person's computer". Sure, there's a LOT more functionality and we can do a lot more now as technology and performance have improved by leaps and bounds. There are some tremendous advantages to that as you can get access to enterprise-level availability, reliability, and even security without shouldering the entire cost of such infrastructure, but it's still just "run and save my stuff on another person's computer".