Select Page

Apache high CPU usage – how to protect your server from overload?

Apache high CPU usage – how to protect your server from overload?

In our role as Server management specialists for web hosting companies, server health monitoring and maintenance is a routine activity we perform in our customers’ servers.

A common issue we notice during server monitoring is the server load intermittently going high, usually caused by Apache high CPU usage. As Apache is a commonly used web server, we give it top priority in our support services.

By running the top command, we can see that Apache takes up about 100% CPU, in this snippet:

100 28480 www-data /usr/sbin/apache2 -k start

A server that has its CPU maxed out, can crash and cause a downtime. So, identifying the reason for Apache high CPU usage and resolving it promptly is a task we perform, as soon as we notice such server issues.

Today, we’ll see how we debug and prevent high CPU usage due to Apache service.


What causes Apache high CPU usage?

In our server management services, we’ve noted various scenarios that can cause Apache to use up the server CPU, some of them being:

  1. A poorly coded web application
  2. 3rd party plugins in applications
  3. Certain Apache modules
  4. Too many users or connections
  5. A single user abusing the server
  6. Vulnerabilities or exploits in web applications
  7. Outdated or insecure Apache version
  8. Malware or malicious scripts in websites or server

To dig in to the actual root cause, we follow an efficient and fool-proof debugging strategy.

[ You don’t have to lose your sleep to keep your web server fast and stable. Click here to know how our Dedicated Server Admins can help you deliver reliable services]


How we debug Apache high CPU usage?

In every load debugging scenario, we follow a systematic 3-step approach to fix the issue.

  1. Find the over-loaded resource – Resource could be CPU, memory, I/O, etc. We examine the ‘top’ results for sometime to pinpoint the problematic resource and service, or else it can lead to wrong debugging.
  2. Find the service hogging that resource – Web, mail, database or any other service in the server can abuse the resource. We map the resource usage with the listed command, to identify the service.
  3. Find the user abusing that service – In a shared server, there may be multiple accounts. So, detecting and suspending the abusive user is very important to assure server stability.

For troubleshooting a physical server or a hardware virtualized instance, ‘atop’ is the tool we use. In an OS virtualization environment, we usually use the regular ‘top’ command. For VPS node troubleshooting, we go for ‘vztop’ utility.

From the results of these utilities, we detect the service that is taking up the CPU resource. Once the service is pinpointed, we find out the process and the user that is hogging up the resources.

To list the files and actions being done by each process, we use ‘lsof‘ command. Using ‘pstree’, we look for any suspicious or high number of processes.

We use ‘netstat‘ and other network related commands to check for too many connections from one particular IP or an IP range. To track the details of certain suspicious commands, we use ‘strace‘ utility.

Enabling extended logging in servers helps us to examine the user specific logs such as access log and error log and to find out the details of high CPU usage for Apache.


Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.


Submit a Comment

Your email address will not be published. Required fields are marked *

Bobcares is a server management company that helps businesses deliver uninterrupted and secure online services. Our engineers manage close to 51,500 servers that include virtualized servers, cloud infrastructure, physical server clusters, and more.