Yet another question on httpd processes

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
jasongr
Forum Contributor
Posts: 206
Joined: Tue Jul 27, 2004 6:19 am

Yet another question on httpd processes

Post by jasongr »

Hi,

I have an apache 2 server that's being hammered with traffic.
I have increased hard_server_limit from 256 and 1024 and recompiled apache.
MaxClients is set to 512.
However, when I do this:
ps -elf | grep httpd | wc -l
I always get 261 processes.
The server is loaded with 4 GB ram and due to heavy traffic, doesn't seem responsive enough.

I have several questions:
1. Will it be beneficial to have more httpd processes to serve more users concurrently, or will it suffice to just increase MaxClients and remain with 261 http processes
2. If above answer is affirmative, how can I increase number of processes beyond 261 (which, I assume, is 256 + elbow of 5)
3. If my server gets 30,000+ unique sessions a day (note that these are not concurrent sesssion), each on average being 10 minutes, what values should I assign to MinSpareServers and MaxSpareServers for optimal performance?

I am, of course, getting more servers soon.

Any learned advice would be appreciated - thanks!
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

On servers with low amounts of RAM (which yours certainly doesn't) it's advisable to bring "StartServers" right down to just a few since these are *always* running even if nobody connects. You may want to fiddle with that so that you have enough clients running all the time to cover about 50% of the total requests at any time.

MaxClients will simply be a hard limit... but it doesn't ever refuse users... If the MaxClients limit is reached and a request comes in the request is simply queued until a process is released.

Talking of releasing httpd proccesses this is a massive point to note in bringing down you RAM usage. httpd proccesses do use a relatively large amount of memory. Even more if you're serving dynamic content with PHP. There's a setting for KeepAlive and KeepAliveTimeout. I'd strongly advise having keepalive turned on so as to allow a single request to retreive a good amount of data in opne shot ( == saved memory on proccess starting overhead). One thing I would do is to bring that Timeout for this right down. Two or three seconds is generally plenty for this value.

The reason you want to keep that value low is that every request that starts a new process will eventually finish but the proccess just sits there doing nothing and wasting valuable RAM while it does so. It sits there for as many seconds as the KeepAliveTimeout. If the page hasn't finished transferring before this timeout the process dies and a fresh one starts to complete the request.

In my experience the two things that really helped bring RAM down (and this was on a 64MB RAM server :P) was StartServers and KeepAliveTimeout.
Post Reply