valyala / fasthttp

Fast HTTP package for Go. Tuned for high performance. Zero memory allocations in hot paths. Up to 10x faster than net/http
MIT License
21.94k stars 1.76k forks source link

How to monitor requests dropped by fasthttp.Server{Concurrency}? #1568

Closed seminmw closed 9 months ago

seminmw commented 1 year ago

Hello!

We want to monitor requests that are dropped by the http.Server{Concurrency} setting and to count the number of rejected requests and write it to prometheus.

Could you make a handler so that something can be done when the request is rejected by ConcurrentLimit here https://github.com/valyala/fasthttp/blob/master/server.go#L1834 ?

erikdubbelboer commented 1 year ago

I don't have time to add this but a pull request is always welcome!

seminmw commented 1 year ago

I don't have time to add this but a pull request is always welcome!

ok, thanks. I'll make a pull request with revision. You also have GetOpenConnectionsCount and GetCurrentConcurrency methods for monitoring, maybe even better add a rejected request method like GetRejectedRequestCount?

erikdubbelboer commented 1 year ago

Sounds like a good idea.