Sunday, April 26, 2009

Using NLB for low budget load-balancing

In a project I worked on a couple of years ago I used NLB to experiment & prove the stateless-ness of the architecture I planned.
NLB is a service that comes with windows servers, it allows to load balance application for better availability.
I'm a fan of hardware load balancing myself, more reliable, dedicated machine for this important task and all sort of programmatic traffic manipulation, but...I realized this information could be useful for lower budget it is.

The Basics

I built the the experiment on two windows 2003 machines, one of them worked as the NLB itself
and application server (machine name "asavasrv01") and the 2nd machine as application machine (machine name "pensionsrv2").
In a real project if you have an old machine that can not perform as an application server you can always use it as the load balancer.
The sample application is win Form client and web service as server.

Setting the NLB cluster

1st step is adding NLB provider to network adapter.

2nd step - set NLB manager for multi cast and add each server to the server list of the NLB manager.

3rd and final step set the load (usually equally for each server, in this case 50%-50%...).

If you set everything your result should be look something like this:

Testing load-balancing

I built the simplest web service returning kinda "hello world" message but with a little tweak - the server name.

The client calls the VIP or cluster name given earlier, we can see the calls are divided between both servers:

Testing Availability

I unplugged one of the server from network to simulate server failure.
we can see the result in the NLB Manager:

On client side, since it calls the server in a loop we experience a failure of a few calls, but after 2-3 seconds the application recovered.

We can see the NLB detected the server failure and passed the load to one server.


After a short setup we saw how the NLB balances the load between the servers and how it detects server failure and keeps the application available!


NLB can not (like other solutions...) detect application failure and does not analyze any server parameters for best performance and availability (and...and..)
it divides the network load between two or more servers in a round-robin order.
Hardly the best load balancing solution, but hey! it's free! if you don't have a budget for a fancy load-balancer solution, you can at least keep your application server more reliable & available.

Think about it!

No comments:

Post a Comment