Go faster server
Eventually everyone looks at their server and thinks, ‘I wonder if we can make it run any faster’. You probably can, but to do so you need to understand how the operating system – in particular, Unix – works. Despite differences in the detail, all Unix systems share the same underlying architecture: a bunch of processes look to the system’s kernel to provide various services, which allow these processes to share the same CPU and that hide the precise workings of peripherals such as disk drives from them. These kernel services implement some type of scheduling to decide which process can run right now, and virtual memory so that each process believes it occupies its own memory space (which may be larger than the machine’s real memory).
As it supports multiple services, the kernel itself requires many simultaneous operations going on inside it, and there are two main ways to achieve this. The most widespread is the monolithic kernel, which consists of one big program – the scheme used in Linux and most commercial Unix systems. However, an alternative approach is to take the simultaneous services out of the kernel itself and implement them as ordinary processes, which leaves you with a tiny kernel called a micro-kernel. The original micro-kernel system was Mach, developed at Carnegie Mellon University in the US, and it is a version of this micro-kernel that lies at the heart of Mac OS X. A few Unix systems adopt a compromise – for example, in Sun Solaris the kernel is a set of threads, similar to the scheme in Windows NT/2000.
You need to understand these different kernel schemes because they are controlled in different ways. Processes are usually under the control of the user, so their performance can be tweaked – the kernel may also be altered by the user, but the fact that it integrates directly with the hardware means changing the hardware can often change the way it works.
So you think your server’s slow?
To discover how to improve the performance of your server, you first have to decide whether it is performing badly (there is never been a machine built whose user has thought ‘that seems fast enough to me’). A server will generally be slow because it lacks enough of one of four resources: processor power, memory, disk bandwidth or network bandwidth. Adding the fastest CPUs, as much memory as possible, fibre-channel RAID arrays and gigabit Ethernet ought to make you happy – but realistically, most of us do not have unlimited budgets. So here are ten steps to improve your Unix server’s performance without spending a fortune:
1. Add more memory
A Unix system will always run faster if you put in more memory. All Unix systems exploit memory that is not being used by processes to cache disk files, so the more memory you have, the less likely it is the kernel will read the same data from the disk twice. Second, the kernel has to keep track of what all the processes are doing, and make complex decisions such as where a particular directory is held on disk. The more memory it has, the more such information it can cache, and the less time it will need to spend shuffling this information within memory. Third, user processes will tend to stay in real memory and will not be swapped to disk via virtual memory. Obviously, memory can be expensive, but do keep an eye on prices regularly – a machine for which 512MB cost an arm and a leg a year ago may cost only £100 per gigabyte nowadays.
2. Run the right kernel
This is one for Linux users – make sure you are running the right kernel for the processor you have. You are probably running a 686 kernel on a Pentium machine, which is correct, but if you find you are running a 386, 486 or 586 kernel (look at the output of the ‘uname -a’ command) then you should check whether that’s correct. More importantly, you may need to run a symmetrical multiprocessing (SMP) kernel if your machine has two or more processors, or the processor supports Hyper-Threading (for example, a Xeon).