4 ms·
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 o
by daakus 16y ago
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.)
- tghw 16y agoI 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?
- jacquesm 16y agoSize your server properly and know the memory requirements of your application. That way you can guarantee that you will never hit swap.
- spudlyo 16y agoThat'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.
- derefr 16y agoThings 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.)
- retube 16y agoWith no swap OOM Killer will kick in if you run out of RAM. It will kill a process in order to free up memory.
- anshul 16y agoThere 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 http://kerneltrap.org/node/3202
- rythie 16y agoAlso 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.