Forum Discussion
iRule optimization
My iRule needs to exact-match on host and wild-card match on path.
when HTTP_REQUEST {
switch [string tolower [HTTP::host]] {
"internal.mycompany.com" {
switch -glob [string tolower [HTTP::path]] {
"/api1/*" {
Is this optimized as it is ? Would re-structuring as a single iRule provide further optimization ?
set $host [string tolower [HTTP::host]]
set $path [string tolower [HTTP::path]]
set $host-uri = "$host/$path"
when HTTP_REQUEST {
switch -glob [$host-uri] {
"internal.mycompany.com/api1/*" {
2 Replies
- nitass
Employee
i think the 1st one is better.
1st[root@ve10:Active] config b rule myrule list rule myrule { timing on when HTTP_REQUEST { switch [string tolower [HTTP::host]] { "internal.mycompany.com" { switch -glob [string tolower [HTTP::path]] { "/api1/*" { } "/api2/*" { } "/api3/*" { } } } } } } ab -n 1000 http://internal.mycompany.com/api3/something [root@ve10:Active] config b rule myrule show all RULE myrule +-> HTTP_REQUEST 1000 total 0 fail 0 abort | Cycles (min, avg, max) = (40248, 54421, 442966) - nitass
Employee
2nd[root@ve10:Active] config b rule myrule list rule myrule { timing on when HTTP_REQUEST { set host [string tolower [HTTP::host]] set path [string tolower [HTTP::path]] set host-uri "$host/$path" switch -glob $host-uri { "internal.mycompany.com/api1/*" { } "internal.mycompany.com/api2/*" { } "internal.mycompany.com/api3/*" { } } } } ab -n 1000 http://internal.mycompany.com/api3/something [root@ve10:Active] config b rule myrule show all RULE myrule +-> HTTP_REQUEST 1000 total 0 fail 0 abort | Cycles (min, avg, max) = (34883, 69650, 510200)
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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