Home > Programming > Checking UNIX Server Performance

Checking UNIX Server Performance

September 18th, 2008

Today, fast load times are crucial to the success of your Website. They improve the user experience, allowing your visitors to take full advantage of your site’s functionality, and ultimately help you gain more traffic. But how can you achieve these fast load times? Good server performance is the answer.

Many Webmasters today don’t bother — or know how — to check a server’s performance. Virtual (or shared) Web hosts might check their servers’ performance now and then; however, if you’re running on a dedicated server, you really need to check its performance on regular basis. If a potential problem isn’t taken care of quickly, it could soon bog down the entire server.

Getting Started

There are many different protocols and other ways to connect to your server, and among the most popular command line variants are Telnet and SSH. Any information you transfer via Telnet is sent in plain text, so anyone running a Network packet sniffer could gain access to any sensitive details you might send.
In order to accommodate the need for security and privacy Secure Socket Shell (SSH) was developed, which is basically a secure version of Telnet that encrypts any information you enter prior to sending the data across the Web. As the SSH read me file technically phrases it,

"SSH (Secure Shell) is a program to log into another computer over a network, to execute commands in a remote machine, and to move files from one machine to another. It provides strong authentication and secure communications over insecure channels. It is intended as a replacement for rlogin, rsh, and rcp."

For more info and help on SSH head to the SSH homepage.

In order to access your server, you’ll need a program capable of using SSH protocols. One of my preferred Windows programs is Putty, which has a nice, streamlined command prompt interface. Once you start Putty or another SSH program of your choice, you’ll need to connect to your Web server before you can run any commands. Some programs will provide a GUI (graphical user interface) through which you can enter your info, while others will provide a command line interface. If you’re left with a plain command line, obviously you’ll need to enter a command in order to connect.

ssh hostname -l username

You’ll need to substitute the hostname with the domain name or IP address of the site you’re connecting to. The -l parameter tells the program to not log you in as root, but under some other username. Submit the command and you’ll be prompted for your password. Note that unlike Windows, with which you’re probably familiar, you won’t see any asterisks as you enter your password. After you’re authenticated, you’ll be logged in.

If you ever forget what username you’re logged in as, you can run this simple UNIX command:

whoami

Once you’re logged in, you are exposed to the world of command line commands of your operating system. Explore all you wish, but try to find out what a command does before you run it. You can obtain a description of what any UNIX command does using the man command, followed by the command you’re interested in learning about. For example:

man top

This will give you an explanation of the top command, which we’ll get into a bit later. Don’t run any commands you aren’t sure about — it just takes one command to wipe your hard drive clean, so be careful!

Server Specifications

What your server can do is greatly affected by the hardware inside it. CPU(s) and RAM are the two main players. How do you know what your server’s capable of? Well, one of the most useful UNIX commands regarding performance is top. It displays the most important data about what’s going on in your server. Here’s a typical example of what you might get as a part of top query result:

7:06pm up 81 days, 7:47, 1 user, load average: 2.90, 2.25, 2.14
214 processes: 209 sleeping, 5 running, 0 zombie, 0 stopped
CPU0 states: 66.3% user, 14.4% system, 27.1% nice, 18.4% idle
CPU1 states: 71.1% user, 14.4% system, 37.1% nice, 13.2% idle
Mem: 3867832K av, 3853780K used, 14052K free, 0K shrd, 100388K buff
Swap: 530104K av, 45980K used, 484124K free 3228192K cached

A Step-By-Step Analysis

Now, let’s go through this information step by step.

7:06pm up 81 days, 7:47, 1 user, load average: 2.90, 2.25, 2.14

The first number is the server time, followed by how many days and hours ago the server was last rebooted. The next figure shows how many users are connected to the machine (through protocols such as SSH). Lastly, come the server load averages. The first number indicates the average number of processes running over the past minute. The second indicates the average over the last 5 minutes. The third shows the average over the past 15 minutes. The next line displays information about process, but we’ll come back to that in a moment. The lines following these first two provide CPU usage statistics (in this example, the server has two CPUs):

CPU0 states: 66.3% user, 14.4% system, 27.1% nice, 18.4% idle
CPU1 states: 71.1% user, 14.4% system, 37.1% nice, 13.2% idle

The foremost CPU is identified by its number (starting at 0). Processor execution modes fall into two categories ? non-privileged mode (user), and privileged mode (system). Privileged mode is often called ‘kernel’ (system) mode; non-privileged mode may be referred to as ‘user’ mode. If executed in non-privileged mode, a process will be able to access only its own memory, whereas in privileged mode, access is available to all of the kernel’s data structures, as well as the underlying hardware. The kernel executes processes in non-privileged mode to prevent user processes from accessing data structures or hardware registers that may affect other processes or the operating environment.

On a UNIX system, each process runs according to what’s called a scheduling priority level. A process called ’scheduler’ distributes CPU time to processes according to their priority, or level. Processes with higher priority level (-20 being the highest) get to run ahead of those with a lower priority. Idle percentage displays the amount of CPU power that isn’t in use. The following two lines give figures about memory and swap file usage:

Mem: 3867832K av, 3853780K used, 14052K free, 0K shrd, 100388K buff
Swap: 530104K av, 45980K used, 484124K free 3228192K cached

The first number represents the total amount available, while the second displays amounts used in kilobytes. The third is the amount free, again in kilobytes, and lastly are the buffer and cache stats. The buffer is the space to which a system writes, before writing to disk, and cache optimizes the performance of your programs.

Labels:Unix, server performance, load analysis, speed

Share This Post

Related stories

Programming , , ,

  1. No comments yet.
  1. No trackbacks yet.