Friday, October 5th, 2007

Load Balancing in your Ajax code

Category: Articles


Lei Zhu developed a Flash site called Voxlite that allows you to send video messages to people. The application uses both Amazon S3 and EC2, and Lei decided to do load balancing between instances on the client side itself.

He wrote up his thoughts on Client Side Load Balancing for Web 2.0 Applications, and wants your comments.

His article discusses:

  • Information on to build a sample Client Side Load Balancing
  • Comparing Server Side Load Balancing to Client Side Load Balancing
  • How an actual Web 2.0 application is using Client Side Load Balancing to achieve reliability and scability
  • How to take advantage of Client Side Load Balancing with Amazon’s EC2 and S3 service.

Posted by Dion Almaer at 6:15 am

3.2 rating from 47 votes


Comments feed TrackBack URI

There are actually a couple of interesting ideas in this article. First of all, server-side load balancing for Amazon’s EC2 elastic computing cloud has a single point of failure. With EC2, you map a domain name to a server using Dynamic DNS. This DNS entry points to 1 server that does the load balancing. If that server goes down, the entire system goes down until the Dynamic DNS entry has been changed. So it seems the client-side solution was a necessity to provide more reliable method of load balancing for EC2. The second point is that using different servers introduces cross-domain loading issues. The author recommends to put the different nodes on sub-domains, rather than on completely different domains: then you can use an iframe to make XHR calls. The third idea I picked up was that the nodes can be in different locations: it would be great if the client connects to the node with fastest response, rather than picking a node randomly. This would allow CDN-type functionality, in addition to fail-over.

Comment by Jep Castelein — October 5, 2007

Flash UI FTW!

@Jep: 1. node with fastest response doesn’t have to be the node with highest throughput (as we need with video uploads), 2. these things (bandwidth/latency) tend to be very dynamic, 3. determining the fastest node costs bandwidth and time, 4. having the nodes in different locations will cost you bandwidth/latency on clustered operations, where the nodes must communicate with each other (a necessity if you want failover and ACID transactions) – it’s better to have the nodes in a single datacenter, but connected to internet via more links/routes/ISPs, but AFAIK only heavy-weights can really afford/justify this.

Comment by ypct — October 5, 2007

@ypct points 1/2/3: this is what CDNs are doing today and charging big money for: they have figured out a way to solve the issues you mention in points 1,2 and 3. Point 4: I was more thinking about loading the static resources and non-personalized dynamic pages from the nearest server. Agree that fully personalized pages are often best served from a single datacenter.

Comment by Jep Castelein — October 5, 2007

Interesting. While client side load balancing has its appeal, I believe it contradicts the basic value of AJAX and entails its downsides. On-server AJAX is sort of a paradigm shift that lets you enjoy the “industrial strength” of the server side without compromising on interactivity, reach, security and the ability to scale. Worth a look –

Comment by navot — October 6, 2007

but… he still needs DNS round robin to solve the single point of failure problem. or am i missing something?

i mean still need to be bound to an ip address to kickstart the app. and if this IP fails, the whole cluster fails.

Comment by Slim Amamou — October 6, 2007

Leave a comment

You must be logged in to post a comment.