Solved

Apache CPU Usage high - troubleshooting

Posted on 2011-02-18
5
2,899 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
  • 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting http://domain.com (http://domain.com) to http…
If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now