ELECTION HASH

Posted by ivanm@a10networks.com

Hi guys,

We can do a similar aFlex?

MD5 calculation of Server + HOST + URI # Rule selects Server that scores highest # # S = Current high score # N = Node being evaluated # W = Winning node # # Set “myPool” to your pool name. # when HTTP_REQUEST { set S “” set myPool pool_name foreach N [active_members -list $myPool] { if { [crc32 $N[HTTP::host][HTTP::uri]] > $S } { set S [crc32 $N[HTTP::host][HTTP::uri]] set W $N } } pool $myPool member [lindex $W 0] [lindex $W 1] # log local0. “URL = http://[HTTP::host][HTTP::uri], CRC32 = $S, NODE = $W, CLIENT IP = [IP::client_addr]” }

Posted by mischa What are you trying to do? URL Hashing? As far as I know we don’t support a variable after “pool” and we don’t support [crc32].

Posted by ivanm@a10networks.com

Persistence per affinity, seeking the same object in the same server.

The idea is to make AX seek the same object in the same cache server, so the objects will not be duplicated in the cache servers.

Posted by mischa

Why could do the hashing with sha1, but still no variable pool. Nor do we support -list in [active_members -list $pool].

Posted by JackofallTrades

so in the example below they are using crc32. This is not recommended because of the high collision rates. You will not get an even distribution. We have MD5 capabilities however we utilize report this as a string and not a int so you can not directly mod the MD5 hash. The reason this is used is because a standard hash will be hosed if one of the nodes go down. So the weight that is added ads stability to the hashing method.

If you change the MD5 sum to an int then you have the ability to make this work. However I am not able to do this. TCL typically trys to handle most expressions as integers. But I am not able to get this to work. This would be required to make the rule work.

when CLIENT_ACCEPTED { set MOD0 3 set MOD1 dog set MOD2 cat set MOD3 egg

set dog [expr [md5 MOD1] % $MOD0] set cat [expr [md5 MOD2] % $MOD0] set egg [expr [md5 MOD3] % $MOD0]

log local0. “Dog is $dog Cat is $cat Egg is $egg” }

Posted by ddesmidt

You all know I’m a big aFleX lover: flexible with no compromise on high performance

But on that specific need: “seeking the same object in the same server.”, we have actually a build-in feature for that specific need under HTTP template: slb template http aaa url-hash-persist xxx

I let you read our 2.6.1 config guide since we have pretty cool options such as: . number of bytes you want to look at . offset in where we look at the url . and ever “server load awareness”

Dimitri

Posted by ivanm@a10networks.com

Thank you. I believe that this option have a lower CPU consumption than would be possible to make with Aflex

Posted by ddesmidt

Our aFleX code is pretty efficient. That said it’s true that build-in templates will be even more efficient.

Also, even if I’m used to create aFleX now, it’s always faster to do: . 1 CLI command “url-hash-persist xxx” or WebUI click . than creating an aFleX script

So for your need, I would go with the template

Dimitri

Posted by ivanm@a10networks.com

Hi all,

I need create this URL Hash, but only for one host header.

I can do URL Hash with aFlex?

Posted by ddesmidt For that corner case, let me propose that solution: You define a VIP as usual to do URL hashing: . service group SG1 . http template URL hash And you bind to that VIP the aFleX below. Note: That aFleX will do round-robin load balancing when the request is NOT for "www.xyz.com".

Code:




when RULE_INIT { set ::rr 0 } when HTTP_REQUEST { if { not ([HTTP::host] ends_with "www.xyz.com") } { switch $::rr { 0 { # server1 node 10.0.2.77 80 set ::rr 1 } 1 { # server1 node 10.0.2.78 80 set ::rr 2 } 2 { # server2 node 10.0.2.79 80 set ::rr 0 } } } }



Dimitri