Forum Discussion
Dayton_Gray_103
Nimbostratus
Aug 21, 2006Help with optimization of this iRule
I have been asked by F5 to post this iRule to see if there are any ways to optimize it as to lower the total CPU usage on the machine. This rule seems pretty straight-forward, but I'm open to suggestions.
Thanks in advance!
when HTTP_REQUEST {
if { (
([HTTP::header User-Agent] matches_regex ".*(\[sS\]lurp|msnbot|\[Ff\]\[Aa\]\[Ss\]\[Tt\]-|/\[Tt\]eoma).*")
or ([HTTP::header User-Agent] matches_regex ".*(\[Gg\]ooglebot/).*")
)
and ([HTTP::header host] eq "www.demodomain.com")
} {
use pool bots.80
}
else {
use pool demo_192.168.1.195.80
}
}
- JRahm
Admin
I would build a class with all the various incarnations. In fact, there is a great example here on DevCentral for your purposes: - unRuleY_95363Historic F5 AccountDepending on whether or not you actually want case insensitive matches, the switch statement is probably your best bet. Also, avoiding any variables will also help get the absolute best performance from the rule.
when HTTP_REQUEST { pool demo_192.168.1.195.80 if { [HTTP::host] eq "www.demodomain.com" } { switch -glob [HTTP::header User-Agent] { *[sS]lurp* - *msnbot* - *[Ff][Aa][Ss][Tt]-* - *[Tt]eoma* - *[Gg]ooglebot* { pool bots.80 Override to new pool } default { pool demo_192.168.1.195.80 } } } else { pool demo_192.168.1.195.80 } }
when HTTP_REQUEST { pool demo_192.168.1.195.80 if { [HTTP::host] eq "www.demodomain.com" } { switch -glob -nocase [HTTP::header User-Agent] { *slurp* - *msnbot* - *fast-* - *teoma* - *googlebot* { pool bots.80 Override to new pool } default { pool demo_192.168.1.195.80 } } } else { pool demo_192.168.1.195.80 } }
- Dayton_Gray_103
Nimbostratus
I was able to use Joe's rule and it works great!
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