[Users] recommended swap space

Kirill Korotaev dev at sw.ru
Fri Dec 7 04:18:04 EST 2007


I wouldn't agree with you that easily.
Usually applications active data set (i.e. data which are frequently accessed)
is ~10-50% of the whole RSS.
Thus it allows to swap out most of apps memory w/o much performance penalty.

I've just checked a couple of production nodes I have access to and see for
example following numbers:
8GB RAM, 2GM swap total, 33 big VEs => 1.2GB swap used
8GB RAM, 16GB swap total, 125 VEs   => ~8GB swap used
both machines work fine and statistics show normal latencies.

I would express it as:
1. swap can hardly be used for memory hungry applications like
   math calculations and similar stuff doing aggressive memory access
2. for common kind of applications swap allows to increase effective memory
   size quite significantly (compares to RAM size) and it also allows
   to provide overcommits for memory, i.e. have a summary of VE limits
   bigger then total RAM. if some of your VEs will have a bust in memory consumtion
   you always know that SWAP will help to handle it.

So depending on this one can select swap size:
a) If you don't know your workload and plan to overcommit your machine,
   swap size 1-2RAM is a good option.
b) If on the other hand you know that your apps will never be able
   to consume whole RAM, then swap can be minimal.

Thanks,
Kirill


Dariush Pietrzak wrote:
>>documentation says swap should be pyhsical RAM*2.
> 
>  This rule was created when HDD were many times faster compared to RAM then
> they are today(and when programs needed way more virtual space in relation
> to what could be available).
>  Imagine how long it would take read/write 32G from HDD..., also, most
> really large requirements for ram come from various layers of essentially
> caching. In the 90s it was quite typical to run servers with half of
> virtual space permanently swapped out ( 64M ram machine, with 128M swap,
> and never less then 64M swap used, 512M machine with 1G swap and never less
> then 512M of swap used etc..). 
>  It was possible to do that, because of large amounts of inactive code/very
> rarely called code in programs, thus you could safely swap out half of the
> code and safely assume that it won't ever be needed. 
>  These days, most of ram goes to data, not to code, and alot of stuff works
> like hash tables - every single particular page of data is accessed relatively
> infrequently (thus, it would be swapped out) but there are a lot of such
> accesses and if you wouldn't want to make them wait for HDD.
> 
>  As a rule of a thumb, I assume that 10000rpm HDD can't handle swap larger
> then ~512M-1G and 1500rpm HDD shouldn't be burdened with more then 1-2G of
> swap.
> 
> 
>>Should I really use 32GB swap space for such machine?
> 
>  If you know that your machine will still run with ~30G swapped out...
> 



More information about the Users mailing list