Re: how to achieve URL hash LB algorithm on ZXTM

Kirk Bauer <[email protected]> Wed, 29 Jul 2009 23:04:16 -0700
Newsgroups gmane.comp.programming.load-balancing.general
Message-ID <4B18A8F75A6384449755BC7784073E9360CFC3E049@exch11.olympus.f5net.com>
This can be done easily via iRules on F5’s BIG-IP.  There is a great article on it on DevCentral.  I believe the most advanced solution (an election hash) has been incorporated as a native feature in TMOS v10.

http://devcentral.f5.com/Default.aspx?tabid=63&articleType=ArticleView&articleId=135



From: [email protected] [mailto:[email protected]] On Behalf Of Eric Y. Zhang
Sent: Wednesday, July 29, 2009 10:46 PM
To: Load Balancing Mailing List
Subject: Re: [load balancing] how to achieve URL hash LB algorithm on ZXTM

thanks. but that is not what I really want. the trafficscript divided traffic based on session, I want something like this

www.abc.com/1.html<http://www.abc.com/1.html> on squid1 permanently
www.abc.com/2.html<http://www.abc.com/2.html> on squid2 permanently


Eric
On Wed, Jul 29, 2009 at 5:19 PM, Ben Mansell <[email protected]<mailto:[email protected]>> wrote:
On 29/07/2009 00:48, Eric Y. Zhang wrote:
routing requests to different backend server in same pool.let's say, I have 5 squid servers behind LB, if LB can do URL hash, then 1of squid server only needs take 20% requests, that helps a lot.

There are a few ways to achieve this. The first is to use the 'perceptive' load balancing algorithm. This takes several factors into account when choosing a node to use, including the URL of a request. However, it's only one of many factors, so it doesn't rigidly enforce the URL->squid server mapping that you probably want.

What you can do instead is to leave the LB algorithm unaltered, and instead use a session persistence class to dictate where each request goes.

Create a 'Universal' session persistence class and assign it to your pool of squid servers. This then lets a TrafficScript rule pick which squid server to use. The TrafficScript command is:

connection.setPersistenceKey( http.getRawURL() );

...and then requests with the same URL will use the same squid server. However, this needs a bit of refinement. You are likely to have many many different URLs going to your squid servers. Each different URL creates a different session persistence mapping, and there are limits on the number of these. To ensure that too many aren't used, we can 'hash' the URL into a smaller set of sessions:

# Hash the URL, then take the first byte, giving 256 different sessions.
# This also uses the website hostname, in case you are caching several
# websites.
$session = string.left( string.hashMD5( http.getHostHeader() .
                                       http.getRawURL() ), 1 );
connection.setPersistenceKey( $session );

So, add this rule in, assign it to your virtual server and then your squid traffic will be nicely divided up. This should improve the cache hit rates.


Ben
_______________________________________________
lb-l mailing list
[email protected]<mailto:[email protected]>
http://vegan.net/mailman/listinfo/lb-l
Searchable Archive: http://vegan.net/lb/archive
http://lbdigest.com Load Balancing Digest
http://lbwiki.com Load Balancing Wiki



--
Life is hard

_______________________________________________
lb-l mailing list
[email protected]
http://vegan.net/mailman/listinfo/lb-l
Searchable Archive: http://vegan.net/lb/archive
http://lbdigest.com Load Balancing Digest
http://lbwiki.com Load Balancing Wiki