Hello Wensong,
the current code of LVS creates a hash table to store
the real server for each persistent client connection.
This often works fine and is independent of the used
protocol. I was thinking about a method which could be
used to keep the information about persistent clients
on the client and not on the loadbalancer.
What about storing the real-server adress inside a cookie?
Now if a client (re)connects, the input chain on the loadbalancer
redirects the connection to an application, through
# ipchains -A input -p tcp -s 0/0 -d ip-address-of-virtualserver:80 -j
cookiefilter
where cookiefilter is an ipchains target which redirects input
onto layer 7, ie. a small daemon running on that host.
Now this daemon checks the http-protocol and looks for a
special cookie containing the IP-address of the real server.
After processing, this daemon redirects the stream back to layer 4,
ie. the LVS code, which then takes the appropriate action.
To get this architecture to work, the real webservers would
have to run the following cgi-script for each session:
#!/usr/bin/perl
use CGI;
my $local_ip = "10.11.12.13";
my $q = CGI->new();
$q->cookie(-name=>'lvs-real-ip', value=>'$local_ip', -expires=>'+1h');
This kind of persistent client connection does have some advandatges
over the built in method. There is no more imbalance of load for
providers using proxys and there is no more need to keep big hash tables
on the loadbalancer.
The disadvantage is, that this only works for http/https, and that the
client has to accept cookies.
What do You think of that proposal?
Jacob
|