Search code examples
haproxy

Check number of requests sent by all clients


I'm currently implementing my new conf for haproxy and I would like to create an ACL based on the number of requests sent.

When I read the documentation there is some check like that but it's dedicated to a specific IP, as:

src_conn_cur  
src_conn_rate 
sc0_http_err_rate()  
sc0_http_req_rate() 

Is there a solution to get all the request sent from every source addresses at the same time? If I reach a specific number of request I want to redirect the users to another backend.


Solution

  • You can use the fe_req_rate fetch.

    You can use this to direct users to another backend like this if the global number of requests per second on the current frontend is above 100 / sec:

    use_backend overflow if { fe_req_rate gt 100 }
    use_backend default