Forum Discussion
I need to create an irule that will reject a specified percnetage of traffic.
Can some one help me in creating an irule that will reject percentage (ex- 50%) of the traffic .
I need this because when there is a heavy traffic my systems are unable to handle ,so i want to apply this irule so that it will drop 50% or 25% of my traffic , so that systems will not be crashed.
He is the sample i am thinking of which is not working
when HTTP_REQUEST {
if { ([string match {/build/apps/medrec/jaml} [HTTP::path]]) }{
HTTP::respond 502 or reject }
}
}
please help.
If there is any better option than reject like sending a fake response for 50% of the traffic that would be more helpful.
HTTP::respond 502 content {
some html tags
}
- hoolio
Cirrostratus
Hi,when HTTP_REQUEST { Check the path if { [HTTP::path] eq "/build/apps/medrec/jaml" }{ For 50% of traffic send a 502 response if { rand() > .50 }{ HTTP::respond 502 content {html...} } } }
- Michael_Yates
Nimbostratus
Hi kimjim, - hoolio
Cirrostratus
Nice idea Michael. - kimjim_51067
Nimbostratus
Hoolio Thank You very much for all your help. - hoolio
Cirrostratus
rand should add very little CPU load or latency. - Ryan_Paras_7933
Nimbostratus
Why not tinker to figure out the high water mark for your application and use something like this... https://devcentral.f5.com/wiki/iRules.HTTPSessionLimit.ashx - tdk_51797Historic F5 AccountFor the 50% case, you could optimise the rule as follows:
- hoolio
Cirrostratus
I like your thinking TDK. But using a local variable for this would be specific to that TCP connection. So if you use that logic, every other HTTP request to the specific URI on each TCP connection would be dropped. I'd guess this wouldn't lead to dropping 50% of requests as some (or most?) clients would not reuse their TCP connections to make multiple requests to that specific URI.
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