Dealing with high load average on Linux server

High load average is an issue which is familiar to almost all server owners who have popular sites and a lot of traffic. Usually it indicates that server can’t properly handle visitors’ requests. This short article aims to describe several simple items to consider while analyzing high load average on your Linux server.

1. MySQL slow query log

For highload projects it’s always better to keep MySQL slow query log enabled to analyze. It could be done this way.

long-query-time = 1

Make sure MySQL has permissions to write slow log. Also note that by MySQL server doesn’t rotate slow log itself. So you would need to do it. It could consume a lot of gigabytes. It’s convenient to analyze slow log with use of mysqlsla tool.

2. Analyzing slow queries

To analyze the slow queries it’s possible to use SQL operator EXPLAIN. It allows to get information on how MySQL server performs the query, if it uses indexes and so on. Here’s an example:

mysql> explain SELECT 1 FROM `archive`.`log` LIMIT 1;

3. MySQL settings, InnoDB, MyISAM

MyISAM and InnoDB are the most often used MySQL storage engines. There are too many differences between them to describe here. But one the most important one is that MyISAM doesn’t support transactions while InnoDB does. Use to get information on MySQL settings and follow the optimization tips. Make sure you understand parameters meaning before changing. If you don’t you’d better ask someone who understands. First optimization tune could be increasing key buffer pool and InnoDB buffer pool. MyISAM keeps in memory only indexes while InnoDB ties to keep the data along with the indexes. So InnoDB would perform the best if its data fits into memory (i.e. if you have 4G of InnoDB data, set innodb_buffer_pool at least to 5-6G). Besides you can use mysqreport and innotop to get more information on what is going on.

4. Swap, IO wait

If your server swaps a lot it will be a one of the sources of performance issues. Since traditional HDD are much slower than RAM the processes could wait for a quite long time to get a response. You can check swap using with top or free commands. One of the most important parameters here is “IO wait”. Here is a sample output of top:

Cpu(s): 12.1%us, 1.8%sy, 0.0%ni, 85.1%id, 0.3%wa, 0.5%hi, 0.2%si, 0.0%st
Mem: 8166644k total, 7773496k used, 393148k free, 165328k buffers
Swap: 8387572k total, 259428k used, 8128144k free, 5404860k cached

If its value is more then 30-40% you might want to optimize your server and/or add more RAM.

5. Apache and nginx

During last several years nginx has gained a high popularity. More and more users decide to use nginx instead of Apache. Although Apache is still one of the most popular web servers and the most featurer one. Since nginx uses epoll for working with the sockets states and file AIO to serve static files, often it performs much better then Apache. So if your application can be deployed with nginx you might want to consider the migration. At present almost all popular CMS and frameworks can be deployed with nginx: Django, Yii, WordPress and so on. Be aware that nginx doesn’t support .htaccess files so if you have them you will need to rewrite them for nginx. Fortunately there are free online converters which can help you with this.

6. Unnecessary services

If don’t need some services it would be better to disable them. It also better from security point of view. On Centos server you can use chkconfig to disable the service. On latest version of Fedora it can be done by systemctl. If you don’t use NFS you can disable all related services and so on.

7. Use performance monitoring software to track the metrics.

There are a lot of both self-hosted and web solutions to track the performance metrics. The graphics allows to analyze the dynamics much easier.

Few things you might want to consider to have reliable server

Ok, let’s say you have a server and run some sites on it. What items do you need to consider it as reliable? Here is a short list of things you might want to have.

1. KVM switch

KVM stands for keyboard, video and mouse. It’s a hardware which allows you to manage your server as if it’s accessible physically. For instance, you upgrade a kernel and a server  becomes inaccessible. KVM could help you to boot with the other one. Ask your host provider about it. Nowadays almost all reliable datacenters provide KVM.

2. Off-site backups

This item is definitely must have. You know, bad things happen. Due to an human or software mistake data could be lost. Filesystems could crash. HDD could fail. To make sure you have all current data you had better to preconsider offsite backups. There are a lot of services which allow to store files, even for free. Try to check and you will find tons of publicly accessible scripts for making backups, both files and databases. One services provide rsync feature, other use FTP. Anyhow you do need the backups. And it would be better to think about before something goes wrong.

3. Reliable remote monitoring service

If you have a site you always want to get it working. provides free monitoring service which aims to maximize your websites uptime. Actually it includes almost all necessary checks to make sure your server is working as it should: HTTP(S), FTP, mail and database checks. Gathered statistics allows you to get  an outages list. Publicly accessible status page lets to get current services state even without authorization.

Welcome to!


We are happy to invite you to start using the simplest free server monitoring service! Our key features include:

  • HTTP(S) (80, 443),
  • FTP (21),
  • IMAP4 (143),
  • POP3 (110),
  • SMTP (25),
  • SSH (22) and MySQL (3306) ports monitoring.

You are free to add up to 10 services per account and 10 contacts per service.  One more convenient feature we provide is an availabilty history which allows you to track services outages. At present we notify you only by email. To share your services current statuses we offer a publicly accessible profiles for each account. It works without authorization so you can easily check it from mobile devices. Try it now!