[PLUG] swap: when to worry

M. Edward (Ed) Borasky znmeb at cesmail.net
Tue Sep 4 14:08:05 UTC 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Kris wrote:
> I have a postgres server with 4GB of ram.
> 
> Let us begin with the numbers:
> 
>              total       used       free     shared    buffers     cached
> Mem:       4049552    4021932      27620          0      11420    1798880
> -/+ buffers/cache:    2211632    1837920
> Swap:      4194296    1125168    3069128
> 
> 
> This box was built less than 48 hours ago, and is in heavy use.  Over these two
> days swap has climbed towards 1GB.
> 
> I know panicking over swap usage is not as easy today as 2.6 likes to swap out
> idle pages over time.  I'm curious how one decides swap is doing too much,
> especially in this case where disk IO is the main bottleneck of a db server.
> Data seems to be going into swap, but not out.
> 
> Also, what are people's opinion on a ramdisk swap drive?  I know, odd, but some
> high-end sites use large ram disk arrays.  I feel running no-swap is dangerous
> to the kernel (and OOM risk), so this would allow an all RAM based VM.  I would
> probably throw in another 4GB of RAM if I attempted to do this.
> 
> Some vmstat (5s intervals):
>  procs -----------memory----------  ---swap-- -----io---- -system-- ----cpu----
>  r  b   swpd   free   buff  cache     si   so    bi    bo   in   cs us sy id wa
>  0  0 1122520  25876  11336 1797028   65    0    89   104  549  686  0  0 99  1
>  1  0 1122480  27972  11288 1795428   24    0  1925    78  727 1017  1  0 89  9
>  1  0 1122412  25708  11520 1797164   34    0   236  1337  742  978  2  0 96  2
>  0  0 1122280  29020  11820 1792488   70    0  1404   222  687  895  2  0 90  7
>  0  0 1122000  28480  11916 1793592  127    0   196   160  706 1026  1  0 98  1
>  0  0 1121800  27496  11996 1794484  103    0   148   121  665  954  1  0 98  1
>  0  0 1121668  26028  12088 1795684   56    0   234    95  625  818  1  0 97  2
>  0  0 1121580  28452  12188 1792180   18    0   544   106  838 1304  3  0 92  4
>  0  0 1121456  26988  12304 1792932   52    0   150   111  604  781  1  0 98  1
>  0  0 1121100  28632  12324 1791332  250    0   343   166  723 1101  1  1 96  2
> 
> 
> ..even after a few minutes writing this email vmstat is showing 0 "so".
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> PLUG mailing list
> PLUG at lists.pdxlinux.org
> http://lists.pdxlinux.org/mailman/listinfo/plug

1. I think you're misinterpreting vmstat. "si" is swap in --
specifically, pages read from swap per second. "so" is swap out -- pages
written to swap per second". The first thing I'd do is make sure you
have the correct versions of the packages "sysstat", "procps" and
"psmisc" for your kernel. By the way, which distro is it?

2. If you look at the "swpd" column, you'll see that it is decreasing.
That's consistent with all swap in and no swap out. What that means is
that at some point, the system *was* writing to swap, but is now reading
back what it wrote.

3. At this point I don't think you have a problem. As far as "in-RAM"
swap, there isn't any need to add swap space of any kind as long as you
are only 1/4 full.

I'd recommend the "Swordfish Book" -- "System Performance Tuning, 2nd
Edition" (O'Reilly System Administration -- Paperback). That will give
you a systematic way of managing Linux resources, and as a bonus, will
give you the same thing for Solaris and other Unix-like systems.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG3WbF8fKMegVjSM8RAp2cAJ91oJiaoM1gGspYMPvTF/xiWwBISgCfbTno
sQIOi+cuP0ByUkrAUK2FjRs=
=4tzp
-----END PGP SIGNATURE-----



More information about the PLUG mailing list