At one time or another every server owner faces high CPU utilization or CPU running at 100%.
It results in sluggish servers, unresponsive application and unhappy customers.
That’s why at Bobcares, we prevent downtime by monitoring and resolving such utilization issues as quickly as they come.
So today, let’s see how we troubleshoot high CPU utilization in Linux servers. But first, a quick look at its causes.
Common causes for high CPU utilization
- Resource issue – Any of the system resources like RAM, Disk, Apache etc. can cause high CPU usage.
- System configuration – Certain default settings or other misconfigurations can lead to utilization issues.
- Bug in the code – An application bug can lead to memory leak etc.
- High traffic – When faced with a high traffic, a system will run out of resources.
Troubleshooting high CPU utilization
To troubleshoot this utilization issue, we first analyze the CPU statistics. They more or less guide us to where the problem lies.
A commonly used command for this is top
. A sample output for the top
looks like this :
%Cpu(s): 16.8 us, 1.5 sy, 0.0 ni, 81.1 id, 0.5 wa, 0.0 hi, 0.1 si, 0.0 st
As we shall see here, these numbers help us identify the probable causes for the high CPU utilization.
1. Resources that may cause high CPU utilization
CPU alone may not be responsible for the utilization problem. We have seen that issues with RAM, Disk etc. are equally responsible. So the first step is to identify any resource responsible for the issue.
For e.g., If with high CPU utilization, we have :
a) High %wa
- It means a high I/O wait time.
- The CPU is waiting for the result of some I/O operation and it is not doing anything else in the mean time.
- In such situations, our experts generally look for and fix high disk I/O.
b) High %st
- It means high “steal time” and it applies only to virtual machines.
- This shows how long the virtual CPU has spent waiting for the hypervisor (the physical server on which the virtual server runs) to allocate the processor.
- In other words, it’s the time “stolen” from a virtual machine.
- When %st is high, it can either mean that the virtual machines are using more CPU or that the virtual machine needs to be moved to another physical server.
c) High %us
- This gives us the user CPU time.
- A high value usually caused by a process run by a user on the system, such as Apache, MySQL or maybe a shell script.
- So, we once again look at the result of the
top
command and find out which process is monopolizing the CPU. - To apply the required fix, our Server Experts first determine the exact thread in the process that is experiencing high CPU and causing the problem.
If you need help in identifying and fixing the resource issue, click here.
2. Configuration fix
We have seen that at times, certain settings can cause an increase in CPU utilization.
Some of the misconfigurations that we have detected and fixed include –
- Apache – Too many users or connections, certain Apache modules, 3rd party plugins in applications etc.
- MySQL – Unoptimized queries taking up more memory, inefficient allocation of memory etc.
Along with these, there may be issues do it PHP, Backup Processes, POP/IMAP, SMTP, Anti-spam processes or Web application firewalls which can cause high load and so on.
3. Application bugs
Sometimes high CPU utilization may be caused by some other underlying issue in the system such as memory leaks.
When there is a problematic script that cause memory leak, then we may have to kill it to stop the CPU utilization from increasing. We have also seen that certain plugins for PHP applications like WordPress, Joomla etc, may also give this issue.
Other causes include Bugs in code, unoptimized queries, outdated softwares etc.
So, if you are facing a similar issue and need help, then click here to talk to our experts here at Bobcares.
4. Traffic spike
A sudden increase in traffic can affect the CPU utilization.
The increased traffic could be due to seasonal traffic, like the Xmas or New Year time or sales related traffic like the Black Friday, Cyber Monday or it could be related to sports like during the World Cup or Super Bowl.
Otherwise it could be that over a period of time, the traffic has increased causing a simultaneous increase in load.
Before determining on the course of action to be taken to deal with the high load, we first verify that it is a legitimate traffic. This is because we have seen that high CPU utilization tends to be one of the symptoms for DoS Attacks.
Once we have verified that the increase is due to genuine traffic, then we solve the utilization issue by optimizing server and resource usage.
Summary
In today’s post we have seen how we troubleshoot the issue of high CPU utilization. If you need help to solve any similar issue that you may be facing, click here to contact our server experts. We are online 24/7.
Geeting,
Dear, the CPU of the http://www.hmu.edu.krd now is 95.83%, and the website show error this because of increase traffic. So, how we can decrease this % and increase the CPU performance?
Best Regards
Hi Dara,
High load just means that your web related services are waiting for one of these resources – I/O, RAM, Net or CPU.
You need to figure out from your top output which resource is being constrained.
Then you need to find out which service is hogging that service and why (usually because database tables are not optimized, or PHP settings are not tuned).
You can chat with our engineer George by clicking on the chat icon on bottom-left. He should be able to guide you better.
Have a great day! 🙂