REST Web Services – Scaling a Restful Web Service Hosted on a Server

load balancingrestscalabilityweb services

We have deployed a restful web service on a application server (Apache). The volume is getting higher and we do want to scale it. We will deploy two more Apache instances on two more machines.

How do I implement a layer which sends request to each of these based on a round robin strategy?

Currently say I have www.mywebservice.com/employees?id=1 and so on.

Now how I redirect these to different instances? Where would the layer come in is I am confused about as I would need some type of facade.

Best Answer

The best way to scale servers in my experience is to do so at the networking level with a separate load balancer.

This sits in front of your webservers and directs incomming requests to a particular webserver and can have quite complex rules for doing so.

For example:

You can add version headers to the request and have the load balencer direct requests to the correct version of the service.

You can have blue/green groups of servers which you take out for no down time upgrades

You can assign load based on each servers response time

Etc

The problem with trying to implement this in your application code is that once the request has reached that level your box is already doing work. this is what you are trying to avoid with load balancing

Related Topic