Forum Discussion
mat1010_230145
Nimbostratus
Oct 21, 2015Rate limit http and https requests globally
Hi @ll
I'm looking for a way to rate limit the requests/sec for all vServices and take an action like displaying a "we are overloaded" page when the requests/sec reaching a specific limit of req...
Oct 21, 2015
I guess you could do this with tables, but you'd have to assign this to all virtual servers and they'd have to use an HTTP profile.
Try something like this?
when HTTP_REQUEST {
set lifetime 1
set requestlimit 10
Add a table entry with a lifetime in seconds of the value of $requestlimit.
table add "Globalcount" 1 indefinite $lifetime
set currentcount [table lookup -notouch Globalcount]
if { $currentcount < $requestlimit } {
table incr -notouch "Globalcount"
HTTP::respond 200 content "All fine"
} else {
HTTP::respond 503 content "Limit reached $currentcount"
}
}
/Patrik
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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