Solved

Apache CPU Usage high - troubleshooting

Posted on 2011-02-18
5
3,093 Views
Last Modified: 2013-11-05
I have a dedicated server with the following hardware:
Dual Intel Xeon-Harpertown 5430-Quadcore [2.66GHz]
6 x OEM 1GB ECC FB-DIMM DDR2 [1GB]
8c211052fa8       Adaptec \ 3405 \ SATA/SAS RAID
4 x dqa0p6500378       Fujitsu MAX3073 SAS MAX3073RC (Raid 10)

We recently moved to this dedicated solution as we outgrew our old VPS.  The new setup is running Plesk 10.1.1.  We have 2 domains on the server (1 very little traffic, the other doing about 1.5TB/month).

The server should be able to handle the load and it appears it is.  The CPU load average is around 1-1.10 at any given time, which is a lot lower than our old VPS. (screenshots included)

The problem though is that the new site is very slow and sluggish compared to the old server, yet this thing has 4 x the amount of RAM, faster hard drives, and a lot more proc power.  I have gone through and optimized the httpd.conf as much as I can.  I tried high values and low values for the prefork StartServers, MinSpareServers, MaxSpareServers, etc.  My current settings are:
StartServers       8
MinSpareServers    5
MaxSpareServers   20
ServerLimit      256
MaxClients       256
MaxRequestsPerChild  4000

I think there is a problem with a script or something that is making the server keep httpd processes active.  We have httpd processes active for up to 25 minutes.  I want to know if there is a way to trace a process to its originating file so that I can trace it back to the script that is calling it.

Thanks for the help.
apache-cpu-usage.png
cpu-load-average.png
0
Comment
Question by:termlimit
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 27

Accepted Solution

by:
Nopius earned 500 total points
ID: 34934039
Hi.

1) Enable extended server status in apache.
Open Apache's httpd.conf and add these lines:
ExtendedStatus On
...
<Location /server-status>
    SetHandler server-status
    Order deny,allow
    Deny from all
    Allow from x.x.x.x y.y.y.y
</Location>
...

Open in new window

Where x.x.x.x is IP address from which you will access /server-status page.

2) Restart apache.

3) When having big load average, open http://yourserver.com/server-status page

4) Find scripts, that have the most 'Req' and 'CPU' values - that's your problematic scripts. Review and profile them and find where the most time is spend. This php tool may help you: http://www.xdebug.org/docs/profiler

Hope this helps.
Regards,
Arty
0
 
LVL 4

Author Comment

by:termlimit
ID: 34934184
Arty,

Thanks for that tip I am going to try that right now and I'll get back to you in a few hours.  I did install apachetop last night and that definitely pinpointed some scripts, but nothing that was out of the ordinary.  Most of the scripts it found were ones that were accessed a lot, which is normal.

Thanks though will check back in.
0
 
LVL 4

Author Comment

by:termlimit
ID: 34934445
Arty,

After further research it appears that the new Plesk Health Monitoring feature is not multi-processor aware.  Since this is the case the processor is actually only using about 5-10% of total CPU percentage.  Right now it is only showing the total CPU usage against 1 core, we have 8.

Thanks for the help and you can get the points, since that tool you provided is actually pretty nice.
0
 
LVL 27

Expert Comment

by:Nopius
ID: 34934563
Thank you for accepting.

> Right now it is only showing the total CPU usage against 1 core, we have 8.

Load average shows CPU queue size, so on 8 cores LA 8.0 means 100% load. So even with a Plesk, that is not aware of multiple cores, you can see your load.


Also I recommend you you to increase some values in config:
MaxSpareServers   50
ServerLimit      512
MaxClients       512

Regards,
Arty
0
 
LVL 4

Author Comment

by:termlimit
ID: 34934587
Arty,

I understand that part of Top from the command line.  The graphs I posted were part of the Health and Monitoring function of Plesk.  This is not accurately showing the Apache CPU Usage against 8 cores, I am not sure where they get this information, but as you can see from the graph above the Total System CPU usage is very low (currently around 10% or so).

I have asked this to the technicians at Plesk as they have no documentation on this.  I did conduct a test on a 4 core, 6 core, and 8 core system.  The load went up by 50% from 4-6, and 33% from 6-8.  This means that the system is basing itself off of 1 core and not the total number of cores.

I have changed those settings in httpd.conf, did that before I even posted this question.  That is why I posted the question, all the normal optimizations were not helping bring down the Apache CPU usage (not to be confused with what Top is showing).

Make sense?
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question