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.
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...}
}
}
}
Have you thought of using Ratio Load Balancing with Connection Limits set on the Servers?
Or you could even use SNMP Monitor to monitor the server and Dynamic Ratio load balancing (you would use the SNMP DCA or SNMP DCA Base Templates). That is described in detail here if you are interested.
Why not tinker to figure out the high water mark for your application and use something like this… DevCentral
This rule “Limits total concurrent HTTP sessions to a pre-defined threshold, allowing those clients with a session cookie to continue once the limit is reached, while redirecting new clients until concurrent sessions are again below the theshold.”
That was you can have some clients have a decent experience instead of randomly getting bumped
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.
You could use a session table entry to create a flag that you increment and then reset to 0 (DevCentral).
However, using expr will give a much more even distribution compared with a local variable, regardless of the connection reuse behavior of clients. And it doesn’t require any session tracking complexity.