Re: how to achieve URL hash LB algorithm on ZXTM
"Eric Y. Zhang" <[email protected]> Fri, 31 Jul 2009 22:24:37 +0800
| Newsgroups | gmane.comp.programming.load-balancing.general |
|---|---|
| Message-ID | <[email protected]> |
Thanks Ben it works like a charm!! TrafficScript is quite impressive. any idea about how TrafficScript impacts the performance of ZXTM? On Thu, Jul 30, 2009 at 6:33 PM, Ben Mansell <[email protected]> wrote: > That is what it achieves. It does this by using a session persistence > mapping that picks a server to use based on the URL requested, and not on > the client. > > > Ben > > On 30/07/2009 06:45, Eric Y. Zhang wrote: > >> 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 > -- 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