Forum Discussion
The_Bhattman
Jul 31, 2011Nimbostratus
Hi Jucao,
Thanks for explanation. This was extremely helpful in understanding your issue.
Let's first approach your first issue where you want to make the iRule more efficient and bring down the cycles, before moving into item 2
The following is the code re-written to use switch commands and expression commands.
when HTTP_REQUEST timing on {
if {[class match $uri starts_with gen3abURLs_SRWD29] } {
log local0. "Entering testi"
set rand [expr { rand() }]
set value_cookie ""
switch -glob [HTTP::cookie value_cookie] {
"1" {
pool cjj1
}
"2" {
Pool cjj2"
}
default {
if { $rand <0.2 } {
Pool cjj1
set value_cookie 1
}
else {
pool cjj2
set value_cookie 2
}
}
}
}
}
when HTTP_RESPONSE {
if {$value_cookie ne "" } {
HTTP::cookie insert name value_cookie value $value_cookie path "/"
}
}
Hopefully that will drop the cycles down enough to be efficient for you.
Bhattman