Portal Home > Knowledgebase > Articles Database > Can someone help me optimize apache?


Can someone help me optimize apache?




Posted by lifetalk, 11-28-2009, 12:21 PM
Alright, I've got apache 2.2 installed on the server w/ eAccelerator. eAccelerator is great, but falls short during heavy traffic/peak times. My MPM worker being loaded is prefork. Here's what it contains: Server Specs: Core i7 920 @ 2.67Ghz 12GB DDR3 RAM 1TB SATA2 HDD 100mbps connection Not sure, but looking at those specs, can someone help me optimize the server? As at peak times, my website stops responding completely. Times out after trying to connect/load for 15-20 seconds! (Server ain't down, cze I can connect via SSH/DirectAdmin just fine).

Posted by Spudstr, 11-28-2009, 12:54 PM
increase start/min/max by 5-7x , drop reqperchild to something between 4k-5k, the higher it goes the more memory it can buildout without expiring though with 12g ram i doubt ram will be your problem. set your disks to noatime as well. the problem of you trying to connect/load for 15-20 secs is the lack of apache processes sitting idle waiting for new connections/loads. and kill keepalive if you have it on.

Posted by ishan, 11-28-2009, 01:44 PM
Go through your apache error logs /etc/httpd/logs/error_log See if there is an error/warning about MaxClients being too low.

Posted by lifetalk, 11-28-2009, 02:54 PM
Thanks I'm going to give all of that a try. Just a question, Where can I check for keepalive? And my site/server also supports download resuming, should the end user need to pause it for any reason. Would killing keepalive break that function? "Set your disks to noatime as well" Can you expand on that please? Have these two errors: Should I double or 3x these two?

Posted by ishan, 11-28-2009, 02:57 PM
Yes, you could increase them quite a bit as you have a high amount of RAM. Try increasing to 750-800 & see if you still get errors. I normally keep them 100-200 above the normal usage. KeepAlive can be found in /etc/httpd/conf/httpd.conf $] cat /etc/httpd/conf/httpd.conf | grep KeepAlive Ishan

Posted by larwilliams, 11-28-2009, 03:09 PM
Before changing MaxClients, I would try increasing the others. MaxClients could be reached because everyone is waiting on a connection at the same time. Try the following: StartServers 20 MinSpareServers 20 MaxSpareServers 20

Posted by Spudstr, 11-28-2009, 03:29 PM
those are incredibly small numbers. Rule of thumb is we keep on average Idle servers = Reqs per second

Posted by tshen83, 11-28-2009, 03:49 PM
The best Apache optimization is called nginx.

Posted by larwilliams, 11-28-2009, 03:56 PM
Care to share your prefork config?

Posted by Spudstr, 11-28-2009, 03:58 PM
I did in my first post. well not all the way, keep min/max 25% +- your average req/s and start 75% your req/s figure.

Posted by larwilliams, 11-28-2009, 04:00 PM
Unfortunately, this software (while a good idea) is probably not suited to the OPs requirement. It has very little in the way of module support or support in the real-world. Apache, on the other hand, is both well known and supported (being the dominant HTTP server). nginx would need at least some support from the major control panel vendors before having a shot at hitting double digit usage %.

Posted by tshen83, 11-28-2009, 04:08 PM
http://interfacelab.com/nginx-php-fpm-apc-awesome/ A lot of people use nginx. Rambler, wordpress, hulu, just to name a few. The problem with apache is the "preforking" model. Each Apache process takes over 50mb or so ram for PHP. It is known for a long time that even running Quercus in Java App Container is faster than PHP+apache.

Posted by larwilliams, 11-28-2009, 05:25 PM
You posted some percentage figures, but not a working config. That is what I was wondering about.

Posted by Spudstr, 11-28-2009, 05:32 PM
Not much to change, remove the modules you don't need, and make the changes on the prefork mpm.. people seem to make it much harder than what it really is. We have plenty of machines pushing couple hundred req/s under apache without any issues.

Posted by larwilliams, 11-28-2009, 05:46 PM
LOL I was asking if you could post the prefork config you use I am curious as to what exactly you use.

Posted by Spudstr, 11-28-2009, 05:51 PM
It varies per customer and what they are doing. Just follow what I suggested and you will be fine. your overall Max settings should limit the amount of max ram - 30%, more if you use mysql on the machine and/or do other services use common sense thats all.

Posted by IfHost, 11-28-2009, 07:02 PM
Just move to litespeed it's so much faster than optimized apahce

Posted by sharmaine1111, 11-28-2009, 10:22 PM
will this work for php running in suphp? or will this work only with fcgi? Because I personally do not want to change from suphp to fcgi for security purposes

Posted by tshen83, 11-28-2009, 11:24 PM
I am not sure, but I think it is fcgi only. The thing is, I don't really see the need for suphp for anything other than multi-tenancy on the same server.(shared server?) If that's the case, then lightweight virtualization is a far better and secure solution. Xen/KVM or Solaris Zones that separate each user into a Virtual Machine is far more secure than suphp ever will be.

Posted by barry[CoffeeSprout], 11-30-2009, 09:02 AM
Which is why there is a worker MPM, it combines multi process masters and threads inside processes to lower memory requirements. Not discounting nginx (which works differently than both prefork and worker) or Quercus (which I like too )



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
Bi-Weekly Cron (Views: 757)
How did YOU learn PHP? (Views: 670)
Windows Reseller? (Views: 752)


Language: