Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Maybe I'm a bit crazy, but I just disable swap all together. With 2 tornado servers, 2 nodejs servers, nginx, postgres, memcache and monit I end up using 170M of memory. (None of the sites are data heavy, so this may be skewed.)


I may be fundamentally misunderstanding something here, but doesn't turning off swap pretty much guarantee that things will start failing if you have a spike in memory usage? Assuming you have something like 256M of RAM (like many small VPSs) running at 170M means that a relatively small spike could cause things to start having memory errors. Is there some way to mitigate this, other than enabling swap?


Things will start "failing" from a user's perspective if you have to hit the disk for every transaction anyway (i.e. most requests will time out.)


Size your server properly and know the memory requirements of your application. That way you can guarantee that you will never hit swap.


That's a lot easier said than done. Unless you use ulimit to strictly enforce process memory limits (tricky) it's nearly impossible to know the how much memory a large complicated program (like MySQL) will allocate.


With no swap OOM Killer will kick in if you run out of RAM. It will kill a process in order to free up memory.


There was a "Is swap necessary" discussion on lkml and kerneltrap[1] a while ago and iirc, someone in the know had said that the kernel does expect to have some swap to work with. So, I run all my machines with about 10M of swap space.

[1] http://kerneltrap.org/node/3202


Also as you try to maximise you memory usage you run the risk of the Out of Memory (OOM) Killer running which just kills of processes and they don't return, till you start them again. It's not nice.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: