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:

%CPU PID USER COMMAND
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.


PREVENT YOUR SERVER FROM CRASHING!

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.

SEE SERVER ADMIN PLANS

Submit a Comment

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

Bobcares
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.
MORE ABOUT BOBCARES

Privacy Preference Center

    Necessary

    Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

    PHPSESSID - Preserves user session state across page requests.

    gdpr[consent_types] - Used to store user consents.

    gdpr[allowed_cookies] - Used to store user allowed cookies.

    PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
    PHPSESSID
    WHMCSpKDlPzh2chML

    Statistics

    Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

    _ga - Preserves user session state across page requests.

    _gat - Used by Google Analytics to throttle request rate

    _gid - Registers a unique ID that is used to generate statistical data on how you use the website.

    smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

    _ga, _gat, _gid
    _ga, _gat, _gid
    smartlookCookie

    Marketing

    Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

    IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

    test_cookie - Used to check if the user's browser supports cookies.

    1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

    NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

    DV - Google ad personalisation

    IDE, test_cookie, 1P_JAR, NID, DV, NID
    IDE, test_cookie
    1P_JAR, NID, DV
    NID