Tuning Apache
Can anyone who has experience on tuning Apache for Linode give me some advice?
I would like to tune Apache to be as responsive as is possible, but not kill the machine if it gets pounded on.
Specs:
Linode 120 - 120Mbytes of RAM
Lots of disk space available
Debian 3.0r1 Small
Apache 1.3
modules running:
modlogconfig
modmimemagic
mod_mime
mod_autoindex
mod_dir
mod_alias
mod_rewrite
mod_access
mod_auth
mod_expires
moduniqueid
mod_setenvif
mod_ssl
mod_lib4php
PHP 4.3.10-16
MySQL 4.0.24
I average ~1000-5000 users per day, maybe 4x that in page views, each page runs on average ~4 MySQL queries.
Can someone suggest a few of the more common httpd.conf settings that would be most appropriate in this setup (ie. MinSpareServers, MaxSpareServers, KeepAliveTimeout, MaxClients, MaxRequestsPerChild) Anything special I can do to lighten the Apache footprint so to speak? Are any of the modules un-needed? I use mod rewrite, mod ssl, mod php for sure, not sure about some of the others.
I realize that my performance issues are much more likely to be MySQL related, but I just want to be sure my Apache is humming along like a fine-tuned machine before touching my.cnf. And yes, I am performing a code audit to try and tighten up the more intensive code and reduce database trips. (EXPLAIN SELECT is great)
Thanks for the advice!
17 Replies
MaxKeepAliveRequests 32
KeepAliveTimeout 20
MinSpareServers 5
MaxSpareServers 10
StartServers 5
MaxClients 10
MaxRequestsPerChild 32
Adjust to suite, but those will get you close. Just for a reference…
For mysql, have a look at these, specifically the buffer values. You could go even lower…
-Chris
I don't suppose you have any way of speeding up SSL processing on Apache… ;-) My server is pretty slow when members are in their secure account areas.
Thanks again!
-Chris
Well, found this article, some of it doesn't apply to linux, but disabling 3DES seems like a good idea for the speed bonus you may get. Am I nuts or would following some of this work?
I did add the SSLCipherSuite line, and it seems more responsive on my SSL pages. Will have to figure out how to test that.
@caker:
MaxKeepAliveRequests 32 KeepAliveTimeout 20 MinSpareServers 5 MaxSpareServers 10 StartServers 5 MaxClients 10 MaxRequestsPerChild 32
Adjust to suite, but those will get you close. Just for a reference…
For mysql, have a look at these, specifically the buffer values. You could go even lower…
http://www.theshore.net/~caker/uml/my.cnf
http://www.theshore.net/~caker/uml/my.c … stable.txt">http://www.theshore.net/~caker/uml/my.cnf-debian-unstable.txt -Chris
Hi Chris,
Do you know if these can also be applied Apache2?
Steve
-Chris
I was running prefork, but am thinking about changing over to worker, as it is supposed to be better.
My only issues are that i use both PHP and TOMCAT, from which java is run via mod-jk and im not sure if worker is compatabile with mod-jk. and PHP will run via suexec.
(btw, the best bet would be "apache2ctl -V | grep MPM" instead of "httpd -V | grep MPM".)
@Internat:
on the note of MPM which one are linoders generally running?
From
High speed threaded model for Apache HTTPD
The worker MPM provides a threaded implementation for Apache HTTPD. It is considerably faster than the traditional model, and is the recommended MPM.
Worker generally is a good choice for high-traffic servers because it has a smaller memory footprint than the prefork MPM.
On my linode, ubuntu hence debian, 'apache2ctl -V | grep MPM' yields
-D APACHEMPMDIR="server/mpm/worker"
I started out with prefork and found that with skunkweb (
James
@Internat:
on the note of MPM which one are linoders generally running?
I just dropped lighttpd after running it for the last ~2 years!? Nothing wrong with lighttpd, just tired of knowing how to do things (config settings) in apache and have to figure out how to pull off the same thing with lighttpd.
I did also need php5 support, but rather than use the pre-fork, I stayed with the threaded model by utilizing mod_fcgid.
If anyone cares how to set up this config rather than write it again… blog posting
I'll monitor and see how it runs over the next couple weeks.
I've a (debian etch) linode 1440 that runs "only" apache2+mysql5+php5, to host a phpbb board with about 300/400 users connected at the same time, and i noted that it use a huge amount of cpu (max 203% avg 69%, about 100~160 in daylight) almost totally used by apache (which use Server MPM: Prefork).
So i wonder if there is a way to decrease the cpu usage.
Thanks in advance.
P.S.
Sorry for my bad english.
@Floppy:
I've a (debian etch) linode 1440 that runs "only" apache2+mysql5+php5, to host a phpbb board with about 300/400 users connected at the same time…
If you are running Apache2 + PHP5 I presume you are using mod_php? So the CPU time used by Apache could have been used by PHP instead.
Tried op-code accelerators like xcache?
@scotty:
Tried op-code accelerators like xcache?
Not yet, how do they work and how can i install (and configure) one of them?
These two are for debian & apache with php5
http://howtoforge.com/apc-php5-apache2-debian-etch
http://howtoforge.com/xcache-php5-apache2-debian-etch
And if you decide to switch to lighthttpd
@Floppy:
Not yet, how do they work and how can i install (and configure) one of them?
As you are on Etch.
$ sudo apt-get install php5-xcache
And just restart Apache after that. You might also look at /etc/php/conf.d/xcache.ini to fine tune your settings (like increasing the cache size since you are running a linode 1440).
Those op-code cache/optimisers basically caches the parsed and compiled PHP byte code in memory so there is no need to re-parse/compile again for subsequent requests. They do a bit more like runtime optimisation and share memory API but they are usually a bit more experimental.