Tuesday, July 10, 2012

How To Configure A Server Load Balancer For Testing With Traffic


What does a server load balancer do?
When  too many users access a particular web site, the server gets overloaded. In order to get rid of this problem a server load balancer is used.


All requests for a Web site arrives at the load balancer that then passes the request to one of the available servers. A load balancer can find out from the servers which one is least loaded, so all of them are doing an equal amount of work.

Internals of a server load balancer

SLB software establishes a virtual server that acts as a front end to physical servers, distributing user service requests among active real servers. SLB packet processing is based on the Network Address Translation (NAT) method. Packets received by the virtual server IP address are translated into the real physical IP address based on the configured distribution metric (for example, “round robin”) and sent to a real server. Packets returned by the real server for the end user are translated by SLB so that the source address is that of the virtual server instead of the real server. NAT is performed for both directions of the traffic flow. Converting virtual services to real services requires IP and TCP checksum modifications.



The server load balancing (SLB) requires associations between the application servers (real
servers) and the virtual server (VIP). The associations are done by binding TCP or UDP ports on the
real servers with TCP or UDP ports on the virtual server. When a client sends a TCP or UDP request
to an application port defined under the virtual server, then the ServerIron identifies one of the
back-end application servers based on the configured load balancing method and forwards the
client request to it. The client is completely unaware of this traffic distribution, but observes
increased availability, faster response time and better throughput. The ServerIron can be
configured to host multiple application services such as web (http), ftp, or DNS under a single
virtual server.


Configurations
~~~~~~~~~~

-----------              -------                     -----------------------             ---------            -----------

Client PC    ------- Router 1------------ Server Load Balancer---------Router 2---------Server PC

-----------              --------                    ------------------------           ----------          -------------

 
The load balancer should be configured with a real server and a virtual server and ports are created under each of them and the real and virtual server ports are bound to each other. Let us say, left side of the load balancer is kept in 1.1.1.0 network and right side in 2.2.2.0 network.

Load balancer Config:
~~~~~~~~~~~~~~~~

interface ethernet 1
 ip address 1.1.1.2 255.255.255.0
!
interface ethernet 16
 ip address 2.2.2.1 255.255.255.0

                interface ethernet 1
                enable
                ip add 1.1.1.2/24
                exit
                int eth 16
                enable
                ip add 2.2.2.1/24
                exit
                server real rs1 2.2.2.2
                port http
                port telnet
                server virtual vs1 1.1.1.4
                port http
                bind http rs1 http

Router 1 and Router 2:
~~~~~~~~~~~~~~~
Enable the  connected ethernet ports and make sure they are up

Client PC
~~~~~~~
 ifconfig eth1 1.1.1.1/24 up               
route add -net 2.2.2.0 netmask 255.255.255.0 gw 1.1.1.2


Server PC
~~~~~~~
ifconfig eth1 2.2.2.2/24 up
route add -net 1.1.1.0 netmask 255.255.255.0 gw  2.2.2.1


TESTING
~~~~~~~

Now send traffic from the client pc to the virtual server's ip (1.1.1.4) using any of the tools listed (Apache bench or Curl). (show server bind in SLB should be Active)

curl http://1.1.1.4
ab -n 10 http://1.1.1.4/


In the load balancer, sessions are created and the transmit and receive packets  are incremented



3 comments: