Re: how to achieve URL hash LB algorithm on ZXTM
Ben Mansell <[email protected]> Tue, 11 Aug 2009 13:53:53 +0100
| Newsgroups | gmane.comp.programming.load-balancing.general |
|---|---|
| Message-ID | <[email protected]> |
If you want to *always* balance the same URLs to the same server, then
this can be done too:
1) Create a session persistence class, this time of type 'Named node', and
assign it to your pool of squid servers.
2) Now, use a TrafficScript rule similar to this to pick the node to use:
# Set this to the number of Squid servers
$nodes = 2;
# Hash the URL to a node to use
$hash = lang.ord( string.hashMD5( http.getHostHeader() .
http.getRawURL() ));
$hash = $hash % $nodes;
if( $hash == 0 ) {
connection.setPersistenceNode( "server1:80" );
} else if( $hash == 1 ) {
connection.setPersistenceNode( "server2:80" );
}
This will force ZXTM to use the same backend for each URL. There is no big
storage mapping URL -> server, it is all done algorithmically.
If a squid server fails, you can control what ZXTM should do via the
'failure mode' for the session persistence class. For example, make it
pick another node to use. When the original server comes back online, it
will start to be used again.
Ben
On 11/08/2009 11:08, Eric Y. Zhang wrote:
> Thanks Ben.
>
> so there is no way for me always to balance same URLs into same squid server. I am thinking to get it done by Java extension(coz I can use getNodes in Java) . The input of java extension is URL, output is the $nodename which I should send traffic into.
>
>
>
>
>
>
> On Tue, Aug 11, 2009 at 4:11 PM, Ben Mansell<[email protected]<mailto:[email protected]>> wrote:
> It is 'by design' that the TrafficScript rule hashes the URLs into ~65000 different 'buckets', but that you should configure ZXTM to remember fewer mappings than this.
>
> ZXTM will store the mappings whatever their value, but will only remember the most recently used mappings. In this way, over time the maps of old URL -> squid server will slowly be forgotten, and a new server will be picked when that URL is seen again.
>
> This will let ZXTM load balance the workload and ensures that any spikes of workload across the cluster will be smoothed out over time.
>
>
> Ben
>
>
>
> On 07/08/2009 12:18, Eric Y. Zhang wrote:
> Hi Ben
>
> $session = string.left( string.hashMD5( http.getHostHeader().http.getRawURL() ), 2 ); is always bigger than universal_cache_size; so when one new URL not in universal cache comes in, ZXTM will balance it using the algorithm I set in the pool?
>
> because I don't have enough memory to store all persistence keys into, so that would be a problem.
>
>
> another interesting question is do you implement the URL hash on your appliance device?
>
>
> I checked iRule from Devcentral of F5 and tried to convert that election Hash into traffic script, but it seems there is no function in traffic script to list active nodes of a pool.
>
> thanks
>
> Eric
>
>
> On Fri, Aug 7, 2009 at 10:02 AM, Eric Y. Zhang<[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>> wrote:
>
> thanks to all of you who discuss this. I learned to many from your threads. this is the most helpful mailing list I ever been.
>
> I will try to figure out the best way to spread load/maintain the availability.
>
> thanks again
> _______________________________________________
> 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