mholt / caddy-ratelimit

HTTP rate limiting module for Caddy 2
Apache License 2.0
255 stars 17 forks source link

[Feature request] Concurrency limiting #69

Open KaKi87 opened 3 weeks ago

KaKi87 commented 3 weeks ago

Hi,

It would be nice to be able to limit the number of requests that a client can make not just in a time range, but concurrently.

For example, if a client has reached a maximum number of allowed simultaneous requests, then another one will be rejected with 429 until at least another one finishes, after which they can try again.

Thanks

mohammed90 commented 3 weeks ago

I think this kind of feature is better implemented in a listener_wrapper rather than an HTTP handler.

mholt commented 3 weeks ago

The benefit of it being an HTTP handler is it can respond with an HTTP 429.

The problem is that a listener wrapper still has to accept the connection to know the IP address, and all it can do is unkindly close the connection after that. (Unless I'm missing something. Quite possible. Running on like 4 hours of sleep today.)

mohammed90 commented 3 weeks ago

The benefit of it being an HTTP handler is it can respond with an HTTP 429.

Good point

KaKi87 commented 3 weeks ago

Would the alternative be letting the request time out ?