Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3546
  • Last Modified:

Apache CPU Usage high - troubleshooting

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
termlimit
Asked:
termlimit
  • 3
  • 2
1 Solution
 
NopiusCommented:
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
 
termlimitAuthor Commented:
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
 
termlimitAuthor Commented:
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
 
NopiusCommented:
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
 
termlimitAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now