Increasing swap
20 Replies
In
> As a base minimum, it's highly recommended that the swap space should be equal to the amount of physical memory (RAM).
@fernandoch:
Is there an official post for this recommendation?
~~[http://library.linode.com/getting-started#sphdeploy-a-linux-distribution " target=" blank">](http://library.linode.com/getting-start … stribution">http://library.linode.com/getting-started#sph_deploy-a-linux-distribution ](
I meant recommended by Linode, not by some distro crap.
The problem might be having a big swap in a virtual environment like this one, but in a physical server, the swap should be well sized.
Shrug. I wasn't very seriously insulting it. You're right, though. I was only thinking in terms of Linode, not the wider use-cases that documentation is written for. In any case, I don't have a position on swap in general; but on Linode, 256 MB plz.
Anyhow, 1:1 ratio of RAM to swap is greatly excessive, be it on a linode or physical server. Desktops are a different story, but for servers, the case for extra swap is pretty poor. Swap is slow. If you need more swap because you don't have enough RAM, adding swap isn't going to solve your problems, it's only going to slow your linode to a crawl.
To put it this way, swap is fine for moving inactive things out of RAM to free up memory. Swap is NOT fine for actively running anything. If you're creeping into swap because of insufficient memory rather than because stuff is inactive, you're in for a very bad day.
While I tend to argue that a 512MB linode can handle enormous loads as a basic LLMP/LEMP/etc stack (into the millions of pageviews per day), if you're maxing out your RAM, you're better getting more RAM than more swap.
@fernandoch:
Well, the Ubuntu distro is the most used in Linode.com…
Ubuntu was designed to become a desktop OS, and for desktop OS it's good advice to set size of swap not less than size of RAM, to use hibernation. But it's not actual for servers.
@OZ:
@fernandoch:Well, the Ubuntu distro is the most used in Linode.com…
Ubuntu was designed to become a desktop OS, and for desktop OS it's good advice to set size of swap not less than size of RAM, to use hibernation. But it's not actual for servers.
Oh really? How come Oracle and Redhat have some minimum swap requirements?
These are no desktops and no hibernation…
There are still edge cases where large amounts of swap can be beneficial. Varnish, for example, eschews disk caching, and instead uses swap as a disk cache. My understanding is that it essentially shoves everything in RAM and then lets the OS figure out what stuff is frequently accessed enough to stay in RAM. Perhaps Oracle does something like this. But failing this kind of specific use of swap, the general case doesn't warrant having much of it.
@fernandoch:
Oh really?
Yes.
@fernandoch:
http://download.oracle.com/docs/cd/B193 … m#sthref63">http://download.oracle.com/docs/cd/B1930601/install.102/b15667/preinstall.htm#sthref63
It's OS recommendations? If you have recommendations for concrete software - it's another case and no reasons to ask this on forum, if you have already strict recommendations.
@fernandoch:
These are no desktops and no hibernation…
Oh, really? RHEL has hibernation.
And, if you don't want to listen answers here - why do you asking here? Ask those authors whose recommendations you cite.
You have recommendation from Linode:
> We strongly recommend sticking with the default swap image size, as allowing your Linode to go heavily into swap can seriously degrade performance in an environment where disk IO is shared among virtual machines.
No more comments from my side.
Thank you all.
Nowadays, as others have said, if you are using swap on a regular basis, then you're hurting your system performance, and should be looking at upgrading. The swap's there just in case, and to provide a warning.
Oracle's demands that you have the same swap as memory are the most annoying… why did you install 64GB in the first place??? I just live with it then throw it away when up and running.
Finally, server loads are generally more predictable than a desktop - and Ubuntu provide both, so their recommendations may well be covering both setups as well. Personally, I don't even install a GUI on my servers, let alone run bloatware like firefox… my poor old workstation has to take that, and it has far more mem than most of my linodes!
Steve.
- Les
How can the swap size be increased?
run command "top"
KiB Mem : 8167504 total, 2714884 free, 900236 used, 4552384 buff/cache
KiB Swap: 1884156 total, 1865968 free, 18188 used. 6830016 avail Mem
then you will know how much Swap you need to set,in my case ,512M or 256M is totally enough.