prometheus-async icon indicating copy to clipboard operation
prometheus-async copied to clipboard

Support for multiple gunicorn workers.

Open aamikus opened this issue 5 years ago • 1 comments

The official python Prometheus client outlines a problem caused by using multiple Gunicorn workers and provides a solution: https://github.com/prometheus/client_python/#multiprocess-mode-gunicorn

I am working on an asynchronous web-app using FastAPI with 4 Gunicorn workers, therefore I cannot use the synchronous Prometheus client. However, this library has no mention of dealing with the multiprocessing issue, and after running some tests, has no built-in solution to deal with it. My question is, is there any plan to add support for multiprocessing? If not, what solution would you recommend? I would prefer to continue using the pull model.

Thank You.

aamikus avatar Nov 28 '19 16:11 aamikus

If your app is async, you can start separate web servers per process. This is actually much better than the sync approach, because it will expose all metrics – including memory.

ptrometheus-async comes with first class support to do that for you with aiohttp but it shouldn't be too hard to adapt to FastAPI? If haven't used it so far myself.

P.S. Sorry for the long delay, I have some thoughts about building something better but just couldn't get around working on it.

hynek avatar Feb 26 '20 09:02 hynek