Extreme Networks Px Series Switch User Manual


 
Px Series Application Switch Installation and Configuration Guide 6-7
Persistence Modes
Using its configured load balancing policy, the Px series application switch selects
one of the web servers. In this example, server 3.
A three-way TCP handshake is established between the Px series application switch
(C) and server 3 (D).
The application switch forwards the first data request from the client to server 3 (E).
The first response from server 3 to the client contains a cookie. (F). The cookie
contains the real IP address of the server, 10.1.1.3.
Each subsequent request sent from the client to the website contains the cookie.
The application switch examines the cookie and sends each request from this client
to server 3. If server 3 fails health checks, the request will be forwarded to another
server.
The following Perl example sends a cookie to the user’s browser, and handles the case
of server failure. If the chosen server fails, then a request will come to a server that
contains the wrong IP address. In this case, the program responds by sending a new
cookie that creates persistence to the new server.
#!/usr/bin/perl
#
# Check and set or reset Server Load Balancer host cookie example
# Uses CGI.pm available at CPAN (www.cpan.org)
use CGI qw(:standard);
$SLBCookie = 'sticky_slba'; # Name of cookie SLB switches on
$HostIPAddr = '10.10.10.106'; # This server's private IP Address
$query = new CGI;
$ExistingHostCookie = $query->cookie($SLBCookie); #Retreive the cookie
if ($ExistingHostCookie ne $HostIPAddr) { #If not set correctly
$NewHostCookie = $query->cookie(-name=>$SLBCookie,
-value=>$HostIPAddr); #Build a new cookie
print $query->header(-cookie=>$NewHostCookie); #include in the header
}
else { # The cookie is correct
print $query->header; # So nothing extra in the header
}
# Example done