One of the sectors where Linux has been at the forefront is the Web server industry. Linux distributions act as servers for a high majority of the websites on the Internet. Apart from websites, they are also used nowadays for Software as a Service, Infrastructure as a Service, etc. platforms, all thanks to its ecosystem centered around security.
Linux Server Load refers to the average work being done by a web server in a given amount of time. It is generally specified in averages of the last 5 minutes, 10 minutes, and 15 minutes.
A higher average server load means that the CPU is being used more, and obviously, access to the server is slow. Apart from this, the memory usage of the system is also considered when server load is being referred to. A server system that runs out of memory can result in its shutdown.
Today, we will learn how to check server load in Linux.
Although the methods described in this article will work even without a server installed on a Linux machine, it would be a good exercise to try them out on a Linux system with a server installed.
You can try to install any common server like Apache or Nginx.
Check Linux Server Load Using Uptime Command
The main purpose of the uptime command in Linux is to show how long the system has been on, i.e., the time elapsed since the last boot. However, it also gives a very quick overview of the load on the system.
What does the load averages, 0.06, 0.03, and 0.00 mean?
As mentioned before these are three averages for the last 1, 5, and 15 minutes. They show the percentage of CPU used in those durations.
Hence, 0.06 means 6% average use of CPU in the last minute, 0.03 means 3% average use of CPU in the last 5 minutes. 0% average use of CPU signifies extremely less use over the span of 15 minutes, which can often be the case if the system is kept in suspend mode.
Check Linux Server Performance Using Vmstat Command
The vmstat command is used to view memory and CPU resource usage in Linux. Instead of displaying averages, it displays the instantaneous usage.
You can simply call it without parameters to get current usage values:
Under CPU, a ‘us’ means resources used by the user, ‘sy’ means resources used by the system, and ‘id’ means the percentage of idle resources.
If you have configured a Swap disk in your system (A partition on a hard drive to be used as RAM if RAM is completely used up), you can see its usage under the ‘swap’ column. If Swap is being used, that is a direct indicator that there is heavy memory usage.
You can also call ‘vmstat’ regularly at intervals to see the loads in near real-time. For example, the following will call vmstat 10 times with an interval of 3 seconds between each call.
$ vmstat 3 10
Notice how at the third call, only 25% CPU is idle, which means there was a load on the server during that time.
We have tried to present a basic understanding of what is meant by server load and explained two commands that can be used to check the server load in Linux. Which commands do you use to check the load on your server? Do let us know in the comments below!