Hello,
I’m rewriting very messy iRules. Currently, they are all if / elseif statements which I am converting to switch statements. Upon going through the rule, I realized that a number of various statments send traffic to the same pool but they are split up. Would it be more efficient to group these together.
Current example:
conditions 1a, 1b, 1c
pools 1
case 1a then
pool 1
case 1b then
pool 1
case 1c then
pool 1
Would it be more efficient to do this:
case (regexp) 1a | 1b | 1c
pool 1
Thanks!
Hi Mark,
I think you would want to use the switch statement, which is similiar to case which is more efficient the the IF-ELSE statements.. Of course it would depend on what you are inspecting in the conditional statement.
Bhattman
I agree with Bhattman, I would guess that a set of switch statements would be more efficient with a default action in case none of the switch statement conditions have been met.
You can also send multiple switch statements to the same location:
when HTTP_REQUEST {
switch -glob [string tolower[HTTP::uri]] {
"/content1*" -
"/content2*" { pool pool.for.content1and2 }
"/content3*" { pool pool.for.content3 }
default { HTTP::redirect http://[getfield [HTTP::host] ":" 1]/content1 }
}
}
“/content1*” -
“/content2*” { pool pool.for.content1and2 }
Perfect. This snippet above was what I was looking for. I’m trying to group requests that go to the same pool. I wasn’t totally sure how to do it in TCL.
Thanks,
Mark