| Author |
Message |
pmmenneg
Joined: 09 Mar 2004
Posts: 41
|
| Posted: Wed Apr 19, 2006 5:49 pm Post subject: Tuning Apache |
|
|
Hi all. Ran into a troubling problem yesterday with a website I host on a Linode 120. Traffic was a bit higher than usual, but the server began to crawl so bad that I could not even log-in via SSL.
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:
- mod_log_config
- mod_mime_magic
- mod_mime
- mod_autoindex
- mod_dir
- mod_alias
- mod_rewrite
- mod_access
- mod_auth
- mod_expires
- mod_unique_id
- 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! |
|
| Back to top |
|
caker
Joined: 15 Apr 2003
Posts: 2392
Location: Galloway, NJ
|
| Posted: Wed Apr 19, 2006 6:16 pm Post subject: |
|
|
Code: 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.cnf-debian-unstable.txt
-Chris |
|
| Back to top |
|
pmmenneg
Joined: 09 Mar 2004
Posts: 41
|
| Posted: Wed Apr 19, 2006 8:45 pm Post subject: This is perfect! |
|
|
This is exactly what I needed. Have tuned Apache, MySQL accordingly.
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! |
|
| Back to top |
|
caker
Joined: 15 Apr 2003
Posts: 2392
Location: Galloway, NJ
|
| Posted: Wed Apr 19, 2006 9:24 pm Post subject: |
|
|
Linode.com is run under a UML Linode (granted, with lots of RAM), but SSL doesn't seem to be an issue there. More info?
-Chris |
|
| Back to top |
|
pmmenneg
Joined: 09 Mar 2004
Posts: 41
|
| Posted: Thu Apr 20, 2006 10:27 am Post subject: |
|
|
In general, it is just a little slow, which I know is a given with SSL. Just looking to make sure I have everything possible tuned up.
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?
http://www.kom.com/apache_tune.html
I did add the SSLCipherSuite line, and it *seems* more responsive on my SSL pages. Will have to figure out how to test that. |
|
| Back to top |
|
sprouse
Joined: 31 Mar 2004
Posts: 7
|
| Posted: Thu Apr 20, 2006 3:13 pm Post subject: |
|
|
caker wrote: Code: 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.cnf-debian-unstable.txt
-Chris
Hi Chris,
Do you know if these can also be applied Apache2?
Steve |
|
| Back to top |
|
caker
Joined: 15 Apr 2003
Posts: 2392
Location: Galloway, NJ
|
| Posted: Sat Apr 22, 2006 4:53 pm Post subject: |
|
|
Apache2 is a little different. You first need to determine which MPM you're running under. To do that, I believe you can run "httpd -V | grep MPM". Once you have that, you can modify the appropriate section of your httpd.conf file.
-Chris |
|
| Back to top |
|
Internat
Joined: 17 Aug 2004
Posts: 174
Location: Brisbane, Australia
|
| Posted: Tue Jul 03, 2007 10:36 pm Post subject: |
|
|
on the note of MPM which one are linoders generally running?
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. |
|
| Back to top |
|
Ciaran
Joined: 13 Feb 2004
Posts: 140
Location: England, UK
|
| Posted: Thu Jul 05, 2007 4:45 am Post subject: |
|
|
I'm using prefork, since I use mod_php and it needs that worker.
(btw, the best bet would be "apache2ctl -V | grep MPM" instead of "httpd -V | grep MPM".) |
|
| Back to top |
|
SteveG
Joined: 30 Nov 2003
Posts: 222
|
| Posted: Fri Jul 06, 2007 12:55 pm Post subject: |
|
|
| The Apache tuning technique I found works best is 'apt-get remove apache && apt-get install lighttpd'. If you need something unique to apache (e.g. Tomcat, I suppose) this is no good, of course, but I've found running PHP under fastcgi with lighttpd to be a lot less memory intensive than Apache/mod_php. Less memory for the webserver means more memory available for the DB, which is always good. |
|
| Back to top |
|
zunzun
Joined: 18 Feb 2005
Posts: 178
Location: Birmingham, Alabama USA
|
| Posted: Sun Jul 08, 2007 7:47 am Post subject: |
|
|
Internat wrote: on the note of MPM which one are linoders generally running?
From http://packages.debian.org/unstable/net/apache2-mpm-worker
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 APACHE_MPM_DIR="server/mpm/worker"
I started out with prefork and found that with skunkweb ( http://skunkweb.sourceforge.net/about.html ) I didn't need it, as the skunkweb processes are independent so I just kill 'em when needed or out of programmatic laziness - the simplest total process cleanup is to kill the process and let skunkweb's process pool manager generate another process in the background.
James |
|
| Back to top |
|
markph
Joined: 16 Jul 2005
Posts: 3
Location: Marietta, GA
|
| Posted: Sun Sep 02, 2007 12:05 am Post subject: Lighttpd to Apach2 |
|
|
Internat wrote: 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. |
|
| Back to top |
|
Floppy
Joined: 06 May 2008
Posts: 3
|
| Posted: Tue May 06, 2008 4:42 pm Post subject: |
|
|
Hi, i'm using this topic instead start a new one because i need help on the same issues (i apologize if i'm wrong).
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. |
|
| Back to top |
|
scotty
Joined: 01 Jan 2008
Posts: 5
|
| Posted: Wed May 07, 2008 12:49 am Post subject: |
|
|
Floppy wrote: 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? |
|
| Back to top |
|
Floppy
Joined: 06 May 2008
Posts: 3
|
| Posted: Wed May 07, 2008 8:04 am Post subject: |
|
|
scotty wrote: Tried op-code accelerators like xcache?
Not yet, how do they work and how can i install (and configure) one of them? |
|
| Back to top |
|
| |