Sunday 2 September 2012

VMSTAT for DBA

What to look in vmstat (For DBA's)

A vmstat output can be used to identify CPU bottlenecks.

Below output shows vmstat output of a typical unix database server.

 procs            memory                        swap        io       system    cpu
 r  b   swpd   free   buff  cache         si   so    bi    bo     in    cs       us sy id wa
 2  5 375912  19548  17556 477472    0    1     0     0      1     1        1  0  0  1
 0  4 375912  18700  17556 478264    0    0  1044   0     774  1329   8  1   0  91
 0  5 375912  17664  17556 479168    0    0  1160   0     764  1110   8  1   0  91


In the above output, we should look for first 2 columns. ie. "r" and "b".

The server experiences bottleneck issues when "r" is greater than the number of CPU’s on the server.

In the above output first row shows "r" is 2. ie. if the CPU count is 2 and "r" is 2, there is no much CPU bottleneck. But "b" shows 5. ie. there are some sessions are waiting. 

It needs more investigation at database level if the waiting sessions are database sessions.

Things to remember in vmstat

r: How many processes are waiting for CPU time.
b: Wait Queue - Process which are waiting for I/O (disk, network, user input,etc..)

Watch command in unix

One more very simple command useful and handy to find the load and CPU starvation.

See the below output

root> w

  7:54am  up 12 days, 12:45,  49 users,  load average: 0.09, 0.11, 0.32
User     tty           login@  idle   JCPU   PCPU  what
root     ttyp1         7:01pm  5:47                tee -a /u01/home/pocj
jjuir    ttyp2         2:48pm    20      3      3  runmenu50 pamenu
uunhik   ttyp3         5:29pm    24                runmenu50 pamenu


The load average is an arbitrary number that shows overall resource consumption of the server. 

Most load average displays have three values for the load average. 

The load average display shows the load averages for the past minute, the past 5 minutes, and the past 10 minutes. 

A low load average is ideal, and the load average should stay below zero. 

Whenever the value exceeds “1” there may be a CPU overload problem.

No comments:

Post a Comment