[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: troubleshooting slow disk writes on squeeze.

Siju George wrote:
> srv1:~# free -m
>              total       used       free     shared    buffers     cached
> Mem:          3956       3538        418          0          0        181
> -/+ buffers/cache:       3356        600
> Swap:         9538         51       9486

That looks okay.  You have 4G of ram and a good amount of swap
configured.  But even with 4G of ram you have used some swap space.

> Vmstat 5 output is here
> http://pastie.org/1240013

That definitely shows swapping.

> cat /proc/meminfo' taken 3 times is here
> http://pastie.org/1240016

Unfortunately I don't have time to analyze that information.  Sorry.

> Am I running short on RAM?

I think so yes.  Or rather you are needing more than you have
available.  You could add more ram.  Or you could reduce your need for
memory.  Look at what processes are running on your machine and
consuming memory.  4G of ram is quite a bit.  If you are consuming
that much and still needing more then I expect to see some large
processes there that are leaking memory.  Find those processes and
take action.

My favorite tool for doing this is 'htop'.

  $ sudo apt-get install htop

Then run it and look at the "Mem" bar in the upper left.  This is a
curses bar graph display of memory use.  Type in 'h' to get a help
script explaining the colors.  Green shows memory used by userland
programs.  Those are just normal programs.  (Usually Firefox. :-) 
Blue and Yellow show memory used in buffer cache.  Memory used in
buffer cache is good memory that is working for you.  The blank area
is free memory.

If your memory is display half green (userland program memory) and
half blue/yellow (buffers / filesystem buffer cache) then I would
consider that healthy enough.  That would show plenty of space for
everything.  If you have just rebooted then I would expect to see a
very little memory used and a lot of blank space showing free memory
that is not yet doing anything.

If the display shows 99% green (userland program memory) consuming
almost all of your resources then that isn't healthy.  That leaves
almost no memory to be used for filesystem buffer cache.  This means
that instead of being able to work from ram that every filesystem
access will need to read the hard disk and wait for the response.
That is much slower than being able to read the file from ram when it
is stored in filesystem buffer cache.  I expect that your system when
it gets into this problem state would show 99% green showing all
memory consumed by userland processes and nothing left for buffer
cache.  And also that all previously used buffer cache had to be
written to disk in order to be freed up.  That also causes a pause
while the disk is being written.

That single line of display is extremely useful to me in understanding
how memory is being used in a system and whether the system is
operating in a healthy state or not.

A note about free memory.  Free memory is memory that is not working
for you.  Some people have a misconception that they should have a
large amount of free memory.  But why?  The Linux kernel is going to
try to put all memory to work for you.  It will dynamically assign
free memory to buffer cache or to program space or to its own
purposes.  If it needs to reclaim some of that cache then it will
dynamically do so.  Therefore you don't need to have a large amount of
free memory.  Memory from userland programs that exit will have all of
their memory freed and that will become free memory.  Over time that
memory will be used by buffer cache or by new programs that are

Then 'htop' can help you find processes that are consuming memory.
The default is to sort the display by percent CPU usage.  But you can
change that to display sorted by resident set size.  Press F6 and then
use the cursor keys to change the sort-by setting to RES and then
Enter.  That will then display the largest memory consuming programs
that are in memory at this time up top.  Those are programs that are
consuming the most memory and are actively using that memory.  (If the
process consumes a lot of memory but doesn't use it then it can be
paged out to disk.  It might consume very little resident memory in
that case and probably isn't really a problem.  Looking at the VIRTual
process size is also useful.)

Look for processes that are consuming all of your memory.

Good luck!

Attachment: signature.asc
Description: Digital signature

Reply to: