MQ_107747
Mar 02, 2011Nimbostratus
Election Hash I-Rule with different Cache Server Type
Hi ,
i wrote irule command for hash election with different cache server type & performance , for example users in subnet (A) will go to Squid cache Server ( SquidPool ) , if there is no pool member available will go for Cache flow servers ( CacheFlowPool ) , if no pool member available will go for Old Cache server ( OldCpool),
and for subnet ( B ) first will check CacheflowPool -> then OldCPool -> then SquidPool
and for subnet (c) first will check OldCPool -> then CacheflowPool -> then SquidPool
all of Loadbalance mechanism will be election hash, i have wrote the following below commands , i need your advise if it is okay :
when HTTP_REQUEST {
set High_Score -9999999999
set Node_Picked ""
Squid Cache Servers
if { [class match [IP::client_addr] equals "UsersSquidServers" ] }{
if { [active_members ] > 0 }{
foreach Cur_Node [active_members -list ] {
if { [crc32 $Cur_Node[HTTP::uri]] > $High_Score } {
set High_Score [crc32 $Cur_Node[HTTP::uri]]
set Node_Picked $Cur_Node
}
}
pool member [lindex $Node_Picked 0] [lindex $Node_Picked 1]
Exit this event from this rule
return
} elseif { [active_members ] > 0 } {
foreach Cur_Node [active_members -list ] {
if { [crc32 $Cur_Node[HTTP::uri]] > $High_Score } {
set High_Score [crc32 $Cur_Node[HTTP::uri]]
set Node_Picked $Cur_Node
}
}
pool member [lindex $Node_Picked 0] [lindex $Node_Picked 1]
Exit this event from this rule
return
} elseif {[ active_members 0 } {
foreach Cur_Node [active_members -list ] {
if { [crc32 $Cur_Node[HTTP::uri]] > $High_Score } {
set High_Score [crc32 $Cur_Node[HTTP::uri]]
set Node_Picked $Cur_Node
}
}
pool member [lindex $Node_Picked 0] [lindex $Node_Picked 1]
Exit this event from this rule
return
}
} end SquidCacheServer
Cacheflowserver
same election hash Algorithem with same command but change the Pool Orders to be :
CacheflowPool -> then OldCPool -> then SquidPool
OldCacheServer
it will be same for above setup with change Pool Order
Else {
any conditions if all cacheServers down !
}
} End I-Rule Statements
appreciate your kind feedback
Best Regards,
MQ