Forum Discussion
Kai_Wilke
Feb 14, 2016MVP
Hi Amichai,
even the smalest iRule may cause performance problems, if you've have already maxed out the capacity of your hardware. But if you have some spare capacity leftover, then this iRule shouldn't be a big deal.
Since performance seems to be a concern, you may try the syntax below. Its basically a carbon copy of your code, but performs ~45% faster...
when RULE_INIT {
array set static::hex2deci {
0 0 1 1 2 2 3 3
4 4 5 5 6 6 7 7
8 8 9 9 a 10 b 11
c 12 d 13 e 14 f 15
A 10 B 11 C 12 D 13
E 14 F 15
}
}
when HTTP_REQUEST {
if { [set hex [string range [HTTP::cookie value "ROUTEID"] 0 0]] ne "" } then {
set member [lindex [active_members -list [LB::server pool]] [expr { $static::hex2deci($hex) % [active_members [LB::server pool]] }]]
pool [LB::server pool] member [lindex $member 0] [lindex $member 1]
} else {
pool [LB::server pool]
}
}
Cheers, Kai