Linux Server – load average
As Magento web shop owner or developer you my have a task to find out why your shop is slow. For this your initial thought my be to check server stats. It is most likely that you shop is hosted on a Linux system, so your primary tools may be uptime or top. Both command line tools show you load average with three numbers. But what does this mean?
Linux Server – load average
Your Magento shop needs processing power from you CPU in a lot of different ways. Some of them are:
- process incoming request (PHP)
- run SQL queries to get requested data (MySQL)
- compute a valid response (PHP)
- run Magento cron (PHP)
- run product import (PHP/MySQL)
There are hundreds of possible tasks. A server can only run one task at a time, so he puts all upcoming tasks into a list and computes them one by one. If a task needs to wait for a resource (for example a file or a query on mysql) it is skipped and another task runs. The command top shows you a detailed list of all these processes and running time. PHP scripts may only run some micro- or milliseconds and then they are destroyed, MySQL task for example needs many hours (it is a daemon).
Load average in numbers?
Load average is measured in numbers. Depending on that you can say that:
- 0.00 is the best. There is are no things to do, your CPU runs 100% idle
- 1.00 means high usage. Your CPU is at 100% workload
- above 1.00 means, that the list of things to do is more as CPU capacity is available
As sysadmin you probably want to have a load average under 1.00. Most admins say that 0.70 is best. But when do I need to be worried?
- under 0.70
everything is going well. You load can go up to 1.00 for some pikes, but needs to go down again early. - above 1.00
if your load is constantly above 1.00 you need to optimize your system. - above 5.00 or more
the server has a problem.
Multicore processors
All the above is true for single CPU systems. Today, most of the servers for Magento 2 have 2 or more CPU cores. A quad-core or a octa-core is no rarity today so you need to know the following. For each full usable core you can divide our average. A simple example:
- on a dual-core system, 2.00 means that your CPU has a 100% workload
- on a octa-core system, 8.00 means that you CPU has a 100% workload
Too easy? I said, that this only counts for a full usable core. On managed systems you often have a quad-core CPU, but you have to share it with other users. If you run a virtual server, things can be totally different. So a base rule can’t be found.
Three numbers
Load average is measured by three numbers. The first is for the last minute, the second for five minutes and the last for 15 minutes. The third number is the best, if you want to know how busy your server is. The first number indicated the current load. The last number is a far better indicator if you want ton find out if there is a problem.
Conclusion
Load average is a big topic for live systems, because a good user experience needs a fast server. If you encounter any weaknesses in your load average, you need to set steps to fix it. You can transfer your shop to a faster server or optimize your scripts. Most of the time it is not clear at this time which option is cheaper.