I'm trying to achieve this scenario :

On a specific path only, I receive a steady 9 requests/sec on the frontend. Everything is fine, use the regular Backend. I now receive 11 req/s, I want to reject any requests above 10. But still want to continue replying to a maximum of 10 req/sec.

Everything I have found and tried implementing (like this : https://blog.codecentric.de/en/2014/12/haproxy-http-header-rate-limiting/), are black or white solution, it drops everything once the rate is reached. So it's a protection against DDOS, abuser, but not a real rate limiting solution.

Is there any way to achieve that ?
PS: using HAproxy 1.5.8

  • 1
    Have you tried maxconnrate? cbonte.github.io/haproxy-dconv/… – Mark Wagner Jul 7 '15 at 21:29
  • Or by using rate-limit sessions <rate> (docs) in the frontend. – GregL Jul 8 '15 at 12:09
  • Sorry, I forgot to add an important requirement, I need to limit just a specific path, not frontend wide. maxconnrate is a global setting and wouldn't work for me.rate-limit sessions does what I want but is frontend-wide. – Bastien974 Jul 8 '15 at 12:53

If you want to use rate-limit sessions, is the following feasible for you?

frontend http_in
   acl is_path url_beg /path/example/
   use_backend forwarder if is_path

backend forwarder
   server localhost send-proxy

frontend limit_path_backend
   bind accept-proxy
   rate-limit sessions 10
   default_backend webnodes
  • 1
    Was about to post it, I got the same solution from the mailing list and confirmed by Willy that it's the recommended way. Note that the last frontend can be a "listen" with the server directly declared in it (instead of having another frontend + backend). – Bastien974 Jul 10 '15 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.