Performance Tuning a Web Server: Part 2

by Mike on February 19, 2009

in Web Server

CPU Usage
When you begin the process of evaluating the CPU usage it is a good idea to gather general information about your CPU so that you have it as a reference.
Several pieces of data are important to gather, the CPU model and MHz, the number of CPUs, the cache, and the bogomips.  Bogomips are an unscientific measurement of CPU speed as “the number of million times per second a processor can do absolutely nothing”.  In other words, don’t get too excited about the output but it is a reference you can use to compare CPUs.

Evaluate Server Performance

Disk Performance

CPU Performance

Memory Performance

I/O Performance

Network Performance

The MHz on a processor will tell you a lot about how fast it is as compared to other CPUs on the market.  It will give you a reference so that if your server is slow you can easily see a way of updating the processor.  The cache is used by the CPU to reduce the time it takes to access memory.  The larger the cache the bigger the impact it will have on speed.

Xeon Web Server
What you see here in the output is an older Xeon dual processor, 3.06Hz.  Note the cache is 512 KB and the bogmips are listed at 6134 and 6130.

cat /proc/cpuinfo

processor    : 0
vendor_id    : GenuineIntel
cpu family    : 15
model        : 2
model name    : Intel(R) Xeon(TM) CPU 3.06GHz
stepping    : 9
cpu MHz        : 3066.014
cache size    : 512 KB
fdiv_bug    : no
hlt_bug        : no
f00f_bug    : no
coma_bug    : no
fpu        : yes
fpu_exception    : yes
cpuid level    : 2
wp        : yes
flags        : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe cid xtpr
bogomips    : 6134.21

processor    : 1
vendor_id    : GenuineIntel
cpu family    : 15
model        : 2
model name    : Intel(R) Xeon(TM) CPU 3.06GHz
stepping    : 9
cpu MHz        : 3066.014
cache size    : 512 KB
fdiv_bug    : no
hlt_bug        : no
f00f_bug    : no
coma_bug    : no
fpu        : yes
fpu_exception    : yes
cpuid level    : 2
wp        : yes
flags        : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe cid xtpr
bogomips    : 6130.79

Once you have collected basic data on the processor then you can move toward some performance data.

Evaluate with uptime. The evaluation of uptime is a simple way to look at CPU usage over a period of 1,5, and 15 minutes on average.  Note that if you have 1 CPU a load average of 1 = 100%, if you had two CPUs then a load average of 2 = 100% and if you had 4 processors a load average of 4 = 100%.

Xeon  (2 CPUs)
A quick review of uptime shows that this machine had lots of room for expansion as the load was much lower than capacity.  If the capacity for 1 minute was .15, 5 minutes was .21 and 15 minutes was .13 this machine is underutilized.

uptime
07:42:51 up 36 days, 19:16,  2 users,  load average: 0.15, 0.21, 0.13

Evaluate with vmstat.

When you view vmstat there are a number of fields that provide information.
Procs reports  the number of running processes “r” and blocked processes (b). The memory section reports swapped memory (swpd), free memory (free), the buffer cache for the I/O (buff) and cached memory for any files that are read from the disk (cache).  The swap section shows memory swapped in (si) and swapped out to disk (so) in kilobytes per second.  The io section shows the number of blocks read in (bi) and blocks written out (bo) in kilobytes per second.  The system section shows the number of interrupts (in) and context switches (cs) per second.  The cpu section shows the  % of CPU with user (us), system (sy),  idleness (id) and processes waiting for I/O completion (wa).

If you run vmstat by itself you will receive one output.  You can also set the interval and the number of iterations.

vmstat 10 15

This command runs vmstat every 10 seconds for 15 iterations.  Here is an example:

vmstat 8 8
procs ———–memory———- —swap– —–io—- -system– —-cpu—-
r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
0  0      0 1992476 130656 506468    0    0    51    12  183  541  4  1 94  1
0  0      0 1992452 130664 506492    0    0     0     5  320  717  3  0 97  0
0  0      0 1992452 130688 506492    0    0     0    20  298  804  1  0 99  0
2  0      0 1992380 130696 506492    0    0     0    16  345  975  1  0 98  0
0  0      0 1992452 130704 506492    0    0     0     2  351  891  2  0 98  0
0  0      0 1992452 130720 506492    0    0     0     6  311  717  1  0 98  0
0  0      0 1992452 130732 506492    0    0     0     2  300  671  1  0 99  0
0  0      0 1992452 130740 506492    0    0     0     3  364  835  2  0 98  0

Practical Application:
One key to focus on is the (wa), as consistent high numbers here is definitely  a problem waiting on I/O.  Usually seeing consistent (wa) in 10+ will show degradation of the system.  Once it reaches 35+ you will not need to look at the statistics as your users will be complaining.

Look for high numbers in either system or user space.  If you see consistent  high numbers for user space it could be an application that has a process that is consuming too much resources.  In this case look at top to see if you can identify the problem process.  If you see consistent high numbers for system then you also need to look into what programs are taking the CPU resources and evaluate their status.

Xeon

procs ———–memory———- —swap– —–io—- –system– —–cpu——
r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
0  0    108 353148 318280 1020900    0    0     0    26    5    2  6  0 94  0  0

Previous post:

Next post: