Python – CherryPy, Load Balancing, and Remote Failover

failoverload balancingpythonweb

Our company's current customer-facing site & intranet site is currently built on Classic ASP running on IIS 6. The current site only contains about 10 customer-facing pages, and an internal site that manages HR records, scheduling, etc.

Management has decided that we will use this rewrite project to finally develop our online retail store. They want us to use a geographically separate facility (also on a completely different ISP) to provide a failover in case the WAN link at our primary facility goes down.

We have chosen Python for the rewrite as we want to be able to move to a Linux-based platform, and we currently use Python in other in-house development projects.

We have looked at the various Python web development frameworks, and CherryPy seems like a good fit for what we need, which is a minimal environment for serving Python-generated content. However, I am having trouble finding information on using CherryPy with load-balancing and failover technologies.

It would appear that we will be forced to host CherryPy on Apache in order to leverage a failover/load-balancing cluster that supports sticky sessions. Is this correct, or this there a way to do it using CherryPy's internal server or a different HTTP server altogether?

Also, are there services that provide a way to direct the traffic in the cluster so that we do not have to host it ourselves? We need to be able to distribute our traffic between the 2 data centers, but if the WAN link goes down at either, it can't affect the ability for the cluster to direct traffic to the cluster that is still available.

Best Answer

There's two main parts to this,
- load balancing and failover across multiple datacenters
- load balancing and failover across multiple servers within a datacenter

There are three main ways to do multi-datacenter: BGP/"anycast", GSLB/DNS, or using an origin-failover mechanism within a CDN. none are simple, easy, or cheap.

Once the users' traffic arrives at a particular datacenter from there you want a loadbalancer component. There are tons of options here that can be broadly categorized as appliance-vs-software and layer4-vs-layer7. Judging from the details you did give I'm gonna bet your needs are pretty simple and your budget pretty small so lets just skip straight to nginx for this part. Within nginx you can configure it to serve your static content and to loadbalance your dynamic content across as many backend servers as you like running your python application.

Good luck, its a long road you've started down.