Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have an apache box running a WordPress website.

For some reason it seems some apache threads are using most of the CPU (10%+), and the remainder little (0.1~).

The box is a dual CPU, Intel(R) Xeon(R) CPU E5620 @ 2.40GHz (which each CPU has 4 cores, and 8 threads).

What is the reason the threads are shown like this, should they not be equal CPU per user?

Is there any set of apache optimizations to help reduce load (CentOS, base apache2 install with PHP and MySQL)?

prefork and worker MPM settings are default below

# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# ServerLimit: maximum value for MaxClients for the lifetime of the server
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule prefork.c>
StartServers       8
MinSpareServers    5
MaxSpareServers   20
ServerLimit      256
MaxClients       256
MaxRequestsPerChild  4000
</IfModule>

# worker MPM
# StartServers: initial number of server processes to start
# MaxClients: maximum number of simultaneous client connections
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule worker.c>
StartServers         4
MaxClients         300
MinSpareThreads     25
MaxSpareThreads     75
ThreadsPerChild     25
MaxRequestsPerChild  0
</IfModule>

high load

share|improve this question
    
How many cpus are in this host? –  Matthew Ife Dec 20 '13 at 22:33
    
2 x ark.intel.com/products/47925, so that makes 8 cores, updated my original post –  g18c Dec 20 '13 at 22:40

1 Answer 1

up vote 2 down vote accepted

For some reason it seems some apache threads are using most of the CPU (10%+), and the remainder little (0.1~).

What you need to take more notice of here is your actual activity. In the snapshot you have provided, the number of running tasks is 7, with a load of 4.

So, at this point in time the number of people needing serving was 7 (probably -- I can only see 6 attributed to httpd though). The remainder are sleeping processes that wont wake up unless some event happens.

The reason you have a high percentage of CPU on some processes are a lower on the other is because only so many of them have something to do within the given second period measured in top.

Is there any set of apache optimizations to help reduce load?

Well, your load probably hovers around 3 to 4 because half the running processes you have probably dont complete within 5 seconds (load is measured internally every five seconds).

  1. There is too many active apache processes there. What are your prefork settings? Try setting it to something more feasible. A max of 72 might be a reasonable start and tune from there. Even if you could serve everyone with that number of processes you'll cause all processes to slow down in equal proportion and load to go up in line with the number of people being served. Better to serve up what you can quickly and reject what you can't serve than serve everyone very slowly.

  2. I get the feeling that some parts of your wordpress page are computationally expensive. Try caching some of this more expensive content.

share|improve this answer
    
Thanks @Mlfe, I've pulled up httpd.conf and edited my original post, you mentioned max of 72, I see MaxClients 256 is this the line you mean? –  g18c Dec 20 '13 at 23:27
    
Well, MaxSpareServers is 20, you shouldn't have that many there unless you have been serving from them. Do you have keepalives turned on? –  Matthew Ife Dec 20 '13 at 23:32
    
KeepAlive Off, MaxKeepAliveRequests 100, KeepAliveTimeout 15. From what I now read, since I have plenty of RAM KeepAlive if turned on would reduce CPU load? –  g18c Dec 20 '13 at 23:53
    
You would handle more of the static requests you are getting in existing running processes rather than handling them in multiple. It would reduce load. –  Matthew Ife Dec 21 '13 at 0:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.