Welcome to WebmasterWorld Guest from 34.204.189.171

Forum Moderators: Ocean10000 & phranque

Message Too Old, No Replies

Apache tuning on Dual Quad Core Xeon

Apache tuning on Dual Quad Core Xeon

     
10:24 pm on Feb 25, 2008 (gmt 0)

New User

10+ Year Member

joined:Apr 1, 2003
posts:16
votes: 0


Hello !

At peak times we get google crawl and server gets load more than 500 ;-)

in the meantime i'm trying to block google bots but i've discovered one big thing,

when load grows i can see that all 8 CPU is not working on 100%

everytime i check htop or vmstat 1, i see cpu usage on 50 % or less, server gets load 600 or so and cpu only 50%, why ? i feel like our server is not well configured,

I have got: Dual Quad Core :
Intel(R) Xeon(R) CPU E5320 @ 1.86GHz

I've got an idea to upgrade to 3GHZ quadcore CPU, but my admin from hosting told me that better CPU don't need to fix this problem, it looks like apache is not well configured for best performance on this server.

we upgraded to latest apache version + latest php version.

btw: I get about 1,3 million pageviews a day on this box.
current settings:

<IfModule prefork.c>
StartServers 10
MinSpareServers 10
MaxSpareServers 20
ServerLimit 1500
MaxClients 1500
MaxRequestsPerChild 4000
</IfModule>

<IfModule worker.c>
StartServers 2
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>

1:27 am on Feb 26, 2008 (gmt 0)

Preferred Member

10+ Year Member

joined:May 4, 2004
posts:525
votes: 0


These directives are a bit confusing, first of all because you are either using the worker, or the prefork MPM, but not the two at the same time - so one set of these directives are there for confusion only. You would need to check out which MPM your are using; first to see which one needs to be tuned, but also to consider (re)building Apache if the other MPM is more beneficial (on high traffic webservers worker MPM is said to be better).

If you are using the prefork one (that's the default if I'm not mistaken), then you can play around with the MaxRequestsPerChild, by increasing it to the double of it (to start with), increase StartServers to something around 200, increase MinSpareServers to 20-30, and MaxSpareServers to 50. These will make the processes die less often (therefore less processes need to be created), and also will keep more processes at hand, so the Apache will generally spend less time on process creation (for the price of a bit higher memory usage).

But this is only about the OS processes, besides of these directives there are many other ones in your Apache configuration and (hopefully not) in your .htaccess files which can severely affect performance, you should read the Apache Performance Tuning [httpd.apache.org] in the Apache documentation, it could be a very good starting point for you.

10:09 am on Feb 26, 2008 (gmt 0)

New User

10+ Year Member

joined:Apr 1, 2003
posts:16
votes: 0


i checked we are using :
<IfModule prefork.c>

so far we started with mod_deflate, it also helped ...

yeah you're right i need to lower nr of requests and make keep die them faster.

8:01 pm on Feb 26, 2008 (gmt 0)

New User

10+ Year Member

joined:Apr 1, 2003
posts:16
votes: 0


i tried your settings but got even worse result..
also seemd that compressing happened even more load, turned it off

Server Version: Apache/2.2.6 (Fedora)
Server Built: Sep 18 2007 11:26:13

--------------------------------------------------------------------------------

Current Time: Tuesday, 26-Feb-2008 20:06:06 CET
Restart Time: Tuesday, 26-Feb-2008 19:55:04 CET
Parent Server Generation: 0
Server uptime: 11 minutes 2 seconds
Total accesses: 96445 - Total Traffic: 207.3 MB
CPU Usage: u198.88 s58.85 cu.58 cs0 - 39% CPU load
146 requests/sec - 320.6 kB/second - 2253 B/request
1500 requests currently being processed, 0 idle workers

maybe i can't get more from that dual quad, i think now about that CPU's with 3GHZ, do you think is there any solution yet ?

forgot to mention, that i use this server only for scripts, mysql and pics are on different machine

5:57 pm on Feb 27, 2008 (gmt 0)

Preferred Member

10+ Year Member

joined:May 4, 2004
posts:525
votes: 0


As I suggested in my earlier post, changing MPM settings is just one side of the coin, you may need to check other settings, as mentioned in the Apache Performance Tuning documentation.

You won't necessarily reach the 100% processor usage, when your script is waiting for disk operations, when it is reading data from the database, those are idle times for the processor. I strongly suggest you to review your httpd.conf for directives which could make the requests served slower (AllowOwerride is a good example of that). In general it is not only the processor which could make a server slower, but the disk and the memory, if you do not have enough memory (a php script for example could easily consume 2 megabytes of ram, without any file or stream operation included, but depending on the modules used, and the actual content of your scripts), so with 1.000 concurrent requests it could go up until 2 gigabytes, without allocating memory for Apache or for the other Apache modules. The disks could also affect the speed, if you have logging enabled, then Apache need to read the scripts, and also write the logs. Newer Apaches has buffered logs, but I did not found them help too much in decreasing the load on the disks.

So what I can suggest is to review your whole Apache configuration, take away modules which are not used, remove (replace) slow directives, and consider switching to the worker MPM. Adding faster CPU's might help indeed, but that only depends on why the system is slow (I guess that's your problem). If the database server giving responses in matter of seconds only, then you better upgrading the database server, not the webserver.

By the way, enabling compression only helps if you have the content already compressed, if Apache (or PHP, or any other language) need to compress it on the fly, that will cost a lot of resources considering the load on you server.