Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We are running bigger deployment with multiple servers running Django applications under apache2 and mod_wsgi.

We are considering switch to apache2 + fastcgi and moving fcgi processes to separate application server "layer".

My question is: how to do proper load balancing between those multiple backend servers? I am most concerned about ability to add and remove servers on-the-fly.

share|improve this question
up vote 1 down vote accepted

What you're proposing is workable; it sounds like you're essentially recreating the architecture which used for their Ruby On Rails install for a while.

But, that said, it would not be my first choice. Why bother with load balancing and add/remove servers over FastCGI, when HTTP is so ubiquitous as it is? Which benefit do you believe you will gain from using FastCGI instead of HTTP?

I would just use an HTTP/HTTPS load balancer as first server, and then speak HTTP to the application server layer. And the application servers could use Apache2+mod_wsgi+Django or gunicorn+Django based on your preference.

There are many good HTTP load balancers available. Search through this site. Some common open-source choices are Perlbal, nginx, HAProxy & Apache 2.2 (in no particular order). There are also commercial appliances like Coyote Point,, or services like Amazon ELB for EC2.

I am most concerned about ability to add and remove servers on-the-fly.

That's a good point, both about taking app servers out of service as well as completely reloading the load balancer config on the fly. Off the top of my head Perlbal, nginx and HAProxy can all reload their config file while running; but I'm haven't verified this just now.

share|improve this answer
We would like to separate usage of webserver vs. appserver, and also put webservers into DMZ. – Almad Feb 25 '11 at 16:34
@Almad: Fair enough, but I still don't see any clear differentiation in doing that via FastCGI vs HTTP. You can do that over HTTP too, and you have a larger selection available in HTTP load balancers. – Jesper Mortensen Feb 25 '11 at 16:40
Well, we must use apache because of some modules that are doing on-fly page rewrites. You are suggesting to just ProxyPass in apache or to put balancer in front of them? – Almad Feb 25 '11 at 16:44
@Almad: If you have extensive Apache know-how and are happy with it, then I'm suggesting: Server 1: Pure load balancer with minimalistic Apache & mod_proxy_balancer. Servers 2 and up: Application servers, with Apache+mod_wsgi+Django. Based on expected load, make your own assesment on where that on-the-fly rewriting belongs. (NB: If your load is high, you could consider using nginx or HAProxy instead of Apache on the load balancer, these are faster than Apache at high request volumes. Also, if your load is high, you're almost certainly going to want Memcached on your app servers.) – Jesper Mortensen Feb 25 '11 at 16:58
I am not, but we have no replacements for those modules ;) We are memcaching extensively, but the separation requirements came from our OPs. Thanks for suggestions, will think about them. – Almad Feb 25 '11 at 17:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.