Forum Discussion

mat1010_230145's avatar
mat1010_230145
Icon for Nimbostratus rankNimbostratus
Oct 21, 2015

Rate 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 requests. This shouldn't depend on ip addresses.

 

It wouldn't be a problem to do this for one specific vService - but I'd like to have this globally through all http and https requests through all vServices. We are running a BIG IP 4200

 

Thanks in advance, mat1010

 

1 Reply

  • 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