Lesson learned: Apache2 MaxClients Variable

Thursday, November 30, 2006
This is an old post originally taken from my blog on Project Opus

Yea, I finally got around to reading about what the MaxClients variable in the apache2.conf is for. Please keep your laughter to yourself, but i thought what MaxClients meant was “how many clients can connect at one time.” So logically, I set it at 255. Well, I’m not sure if MaxClients is a cryptic name, or maybe I just missed the boat, but actually this variable controls how many server processes will run simultaneously!

Visually stated: MaxClients == MaximumNumberOfApacheInstancesRunningAtTheSameTime

So what? Well, when load got high, apache would start spawing “hefty” Drupal processes @ between 20MB and 80MB each.

Simple math: 255×60MB = 15,300 MB RAM usage (hint: we don’t have 15 GB of RAM)

As you can see this is a bad situation.

I changed the nubmer to 40 this morning and systems haven’t been happier :-)

Lessons learned … lessons learned

James.

Comments

by Mike
So if you set MaxClient to 40 that means you have 40 processes running. If say 40 processes are running at 60MB like your example shows you would need 2.4GB of ram to handle this. And as we know most people do not have that much ram on their computer.

So how is this going to work?

by James Andres
Exactly, so if you have less RAM then just use a smaller number (like 10 or 20).

This is a classic example of why big iron servers have insane amounts of ram. I once talked to a sys-admin who ran a Sun Solaris cluster with over 60 GB of RAM!

by Mike
Wow thats a lot of RAM. However I guess that makes sense to have that much on the server since sometimes you might need it!
by Jukka T
Most of the memory between the Apache processes is shared. The memory is allocated one and shared between the processes. So it’s not correct to take a size of one process and multiply it by the number of processes.
James-andres-165-bw James Andres

Country: Canada
About

Hello! Welcome to the current online home of James Andres, myself.

I'm a web developer, system administrator, and all-round geek.

This site is a journal of my life as it relates to techology.

Kudos and Link Bait

I work at Donat Group Enterprises building social networks, often with the Drupal CMS, of which I am a contributor. You may remember me from such sites as Project Opus.

Ross Howard-Jones is a brilliant designer who helped prettify this site. David Gratton inspired me to get off my ass and put this site together.

This site was built with the great language Ruby on the so-so platform Rails.