Forum Discussion
Sekou_Page_1118
Nimbostratus
Apr 26, 2006HTTP_Request URI performance question
I would like to know which type of request is more efficient as iRules get longer. We have a need to direct clients to specific pools of web servers depending on the URL they used. However, we have literally hundreds of URLS, which means very long iRules. We are looking into changing this (I have another post on this for suggestions).
Anyway, here are the two types of rules we can use... Keep in mind that the actual rules would be for several hundred URLS. So if anyone out there knows of a performance difference between these two types of rules, please let me know. Thanks!Example1:
when HTTP_REQUEST {
if { [HTTP::uri] contains "/c1/"} {
pool WEB02
}
elseif { [HTTP::uri] contains "/c2/"} {
pool WEB02
}
elseif { [HTTP::uri] contains "/d1/"} {
pool WEB01
}
elseif { [HTTP::uri] contains "/d2/"} {
pool WEB01
}
} else {
pool WEB03
}
}
Example2:
when HTTP_REQUEST {
if { [HTTP::uri] contains "/c1/" or [HTTP::uri] contains "/c2/"} {
pool WEB02
}
elseif { [HTTP::uri] contains "/d1/" or [HTTP::uri] contains "/d2/"} {
pool WEB01
}
else {
pool WEB03
}
}
- JRahm
Admin
Try this:class myURI { "c1 WEB02" "c2 WEB02" "d1 WEB01" "d2 WEB01" } when HTTP_REQUEST { set myPool [findclass [string tolower [HTTP::uri]] $::myURI " "] if { info exists $MyPool } { pool $MyPool Next 3 lines only necessary if /[cd][12]/ needs to be trimmed from the URI set preURI [string trimleft [HTTP::uri] "/"] set finalURI [string trimleft $preURI "/"] HTTP::uri "/$finalURI" } }
- unRuleY_95363Historic F5 AccountYou should also consider using a Tcl switch statement, which also has pretty good performance (much better than the if-then-else approach).
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