System Tuning

Contact:http://www.packetnexus.com

System Tuning Info for Linux Servers
This page is about optimizing and tuning Linux based systems for server
oriented tasks. Most of the info presented here I've used myself, and have
found it to be beneficial. I've tried to avoid the well tread ground
(hdparm, turning off hostname lookups in apache, etc) as that info is easy
to find elsewhere.
Disk Tuning
File system Tuning
SCSI Tuning
Network Interface Tuning
TCP Tuning
File limits
Process limits
Threads
Apache and other web servers
Samba
Openldap tuning
Sys V shm
Benchmarks
System Monitoring
Utilities
System Tuning Links
Music
TODO

File and Disk Tuning

Benchmark performance is often heavily based on disk I/O performace. So
getting as much disk I/O as possible is the real key.
Depending on the array, and the disks used, and the controller, you may want
to try software raid. It is tough to beat software raid performace on a
modern cpu with a fast disk controller.
The easiest way to configure software raid is to do it during the install.
If you use the gui installer, there is options in the disk partion screen to
create a "md" or multiple-device, linux talk for a software raid partion.
You will need to make partions on each of the drives of type "linux raid",
and then after creating all these partions, create a new partion, say "
/test", and select md as its type. Then you can select all the partions that
should be part of it, as well as the raid type. For pure performance, RAID 0
is the way to go.
Note that by default, I belive you are limited to 12 drives in a MD device,
so you may be limited to that. If the drives are fast enough, that should be
sufficent to get >100 mb/s pretty consistently.

File System Tuning

Some of the default kernel paramaters for system performance are geared more
towards workstation performance that file server/large disk io type of
operations. The most important of these is the "bdflush" value in
/proc/sys/vm/bdflush
These values are documented in detail in
/usr/src/linux/Documenation/sysctl/vm.txt.
A good set of values for this type of server is:
echo 100 5000 640 2560 150 30000 5000 1884 2 > /proc/sys/vm/bdflush
(you change these values by just echo'ing the new values to the file. This
takes effect immediately. However, it needs to be reinitilized at each
kernel boot. The simplest way to do this is to put this command into the end
of /etc/rc.d/rc.local)
Also, for pure file server applications like web and samba servers, you
probably want to disable the "atime" option on the filesystem. This disabled
updating the "atime" value for the file, which indicates that the last time
a file was accessed. Since this info isnt very useful in this situation, and
causes extra disk hits, its typically disabled. To do this, just edit
/etc/fstab and add "notime" as a mount option for the filesystem.
for example:
/dev/rd/c0d0p3          /test                    ext2    noatime        1 2
With these file system options, a good raid setup, and the bdflush values,
filesystem performace should be suffiecent.

SCSI Tuning

SCSI tuning is highly dependent on the particular scsi cards and drives in
questions. The most effective variable when it comes to SCSI card performace
is tagged command queueing.
For the Adaptec aic7xxx seriers cards (2940's, 7890's, *160's, etc) this can
be enabled with a module option like:
	aic7xx=tag_info:{{0,0,0,0,}}
This enabled the default tagged command queing on the first device, on the
first 4 scsi ids.
	options aic7xxxaic7xxx=tag_info:{{24.24.24.24.24.24}}
in /etc/conf.modules will set the TCQ depth to 24
You probably want to check the driver documentation for your particular scsi
modules for more info.

Network Interface Tuning
Most benchmar