Forum Discussion
irule-not-matching-uri-as-expected
I have the following iRule setup which allows me to request a pool based on uri.
when RULE_INIT { set req_count 0 after 60000 -periodic { set req_count 0 } }
when HTTP_REQUEST { if {[HTTP::uri] matches_regex "^/data/main.js\?id=100\&."} { incr ::req_count if { $::req_count > 40000 } { HTTP::respond 503 Retry-After 3 } use pool siteA_http_pool } elseif {[HTTP::uri] matches_regex "^/data/main.js\?id=200\&."} { use pool siteB_http_pool } elseif {[HTTP::uri] matches_regex "^/data/main.js\?id=300\&.*"} { use pool siteC_http_pool } else { use pool siteD_http_pool } }
rule to siteA_http_pool is enable.expected movement.
but
{[HTTP::uri] matches_regex "^/data/main.js\?id=200\&.*"}use pool siteB_http_pool
&
{[HTTP::uri] matches_regex "^/data/main.js\?id=300\&.*"}use pool siteC_http_pool
are not expected movement. this two rule is invalid, access to siteD_http_pool..
Where is my mistake ?
1 Reply
- Henrik_Gyllkran
Nimbostratus
Is the use of regexp necessary in this case? I was told to avoid regexp whenever possible since they are rather CPU intensive. In this case I think you could just use starts_with instead:
{[HTTP::uri] starts_with "/data/main.js?id=100&"}
Of other notice is that you're using req_count as a global variable, which is really bad for performance since it will demote the virtual server associated with this iRule to a single CPU core. That whole thing is to limit the number of requests to siteA_http_pool, right? I think there would be more efficient ways to do that. Let me think on that.
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