Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
 Post subject: Tuning Apache
PostPosted: Wed Apr 19, 2006 6:49 pm 
Offline
Senior Member

Joined: Tue Mar 09, 2004 3:52 am
Posts: 106
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!


Top
   
 Post subject:
PostPosted: Wed Apr 19, 2006 7:16 pm 
Offline
Linode Staff
User avatar

Joined: Tue Apr 15, 2003 6:24 pm
Posts: 3090
Website: http://www.linode.com/
Location: Galloway, NJ
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.c ... stable.txt

-Chris


Top
   
 Post subject: This is perfect!
PostPosted: Wed Apr 19, 2006 9:45 pm 
Offline
Senior Member

Joined: Tue Mar 09, 2004 3:52 am
Posts: 106
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!


Top
   
 Post subject:
PostPosted: Wed Apr 19, 2006 10:24 pm 
Offline
Linode Staff
User avatar

Joined: Tue Apr 15, 2003 6:24 pm
Posts: 3090
Website: http://www.linode.com/
Location: Galloway, NJ
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


Top
   
 Post subject:
PostPosted: Thu Apr 20, 2006 11:27 am 
Offline
Senior Member

Joined: Tue Mar 09, 2004 3:52 am
Posts: 106
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.


Top
   
 Post subject:
PostPosted: Thu Apr 20, 2006 4:13 pm 
Offline
Senior Newbie
User avatar

Joined: Wed Mar 31, 2004 8:50 pm
Posts: 7
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.c ... stable.txt

-Chris


Hi Chris,

Do you know if these can also be applied Apache2?

Steve


Top
   
 Post subject:
PostPosted: Sat Apr 22, 2006 5:53 pm 
Offline
Linode Staff
User avatar

Joined: Tue Apr 15, 2003 6:24 pm
Posts: 3090
Website: http://www.linode.com/
Location: Galloway, NJ
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


Top
   
 Post subject:
PostPosted: Tue Jul 03, 2007 11:36 pm 
Offline
Senior Member
User avatar

Joined: Tue Aug 17, 2004 11:37 pm
Posts: 262
Website: http://www.our-lan.com
WLM: nf@our-lan.com
Location: Brisbane, Australia
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.

_________________
ServerAdmin - www.our-lan.com
"Diplomacy is the art of saying nice doggy whilst looking for a really big stick"
"In my experiece, any attempt to make any system idiot proof will only challenge God to make a better idiot"


Top
   
 Post subject:
PostPosted: Thu Jul 05, 2007 5:45 am 
Offline
Senior Member

Joined: Fri Feb 13, 2004 11:30 am
Posts: 140
Location: England, UK
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".)


Top
   
 Post subject:
PostPosted: Fri Jul 06, 2007 1:55 pm 
Offline
Senior Member

Joined: Sun Nov 30, 2003 2:28 pm
Posts: 245
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.

_________________
The irony is that Bill Gates claims to be making a stable operating system and Linus Torvalds claims to be trying to take over the world.
-- seen on the net


Top
   
 Post subject:
PostPosted: Sun Jul 08, 2007 8:47 am 
Offline
Senior Member

Joined: Fri Feb 18, 2005 4:09 pm
Posts: 594
Internat wrote:
on the note of MPM which one are linoders generally running?


From http://packages.debian.org/unstable/net ... 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


Top
   
 Post subject: Lighttpd to Apach2
PostPosted: Sun Sep 02, 2007 1:05 am 
Offline
Newbie

Joined: Sat Jul 16, 2005 10:29 am
Posts: 3
Location: Marietta, GA
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.


Top
   
 Post subject:
PostPosted: Tue May 06, 2008 5:42 pm 
Offline
Newbie

Joined: Tue May 06, 2008 5:28 pm
Posts: 3
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.


Top
   
 Post subject:
PostPosted: Wed May 07, 2008 1:49 am 
Offline
Junior Member

Joined: Tue Jan 01, 2008 4:28 am
Posts: 32
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?


Top
   
 Post subject:
PostPosted: Wed May 07, 2008 9:04 am 
Offline
Newbie

Joined: Tue May 06, 2008 5:28 pm
Posts: 3
scotty wrote:
Tried op-code accelerators like xcache?


Not yet, how do they work and how can i install (and configure) one of them?


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group