2

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.

Almad
  • 151
  • 7

1 Answers1

1

What you're proposing is workable; it sounds like you're essentially recreating the architecture which eins.de 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, Loadbalancer.org, 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.

  • 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. –  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
  • 1
    @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.) –  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