Samba – Resolving high iowait on Samba server

cacheiowaitsamba

We've got a centralised file cache which a cluster of web servers use to store "heavyweight" pages. Each webserver uses Samba to mount this shared area.

We're getting a lot of iowait on the server, and I wondered what steps we could take to make a more efficient centralised cache? We're already using memcache as first line cache for some objects, and may simply throw more memory at that, but I'm interesting in finding out what techniques we could use to speed up a file based cache. All the servers run recent release of Ubuntu.

The server uses an ext3 filesystem with LVM. Maybe other filesystems would be more performant for this sort of activity? We used Samba for many years simply because everyone is comfortable with it and we had maintenance headaches with NFS (refusal to unmount, for example). Maybe there's better technologies…

Best Answer

Check the io scheduler (called the io elevator in the kernel documentation) assigned to that volume.

$ cat /sys/block/sda/queue/scheduler 
noop anticipatory [deadline] cfq 

For most RedHat and Fedora distros the default is the CFQ scheduler. IMHO this is not the best for an iobound server process. I recommend the deadline scheduler

$ echo "deadline" > /sys/block/sda/queue/scheduler

to change this, or add

elevator=deadline

to your boot arguments to make this permanent.

High iowait times can also be caused by aggressive readahead, which may be unnecessary for your workload. The default for RedHat and Fedora systems is 128k

$ cat /sys/block/sda/queue/read_ahead_kb 
128

Experiment with echo'ing lower values to that file and see if that decreases your iowait times.

Also, check the underlying disk or array. If it is degraded, or rebuilding, your iowait times will skyrocket as the underlying disk subsystem steals io bandwidth while rebuilding itself

Related Topic