Forum Discussion
Mark_Stradling_
Cirrus
Jul 01, 2010Case Statement Efficiency
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!
- The_Bhattman
Nimbostratus
Hi Mark, - Michael_Yates
Nimbostratus
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.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*" -
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects