Skip to content

Gunicorn integration gunicorn.workers likely to gauge workers blocked on network I/O as idle #20171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
david-huber opened this issue Apr 28, 2025 · 0 comments

Comments

@david-huber
Copy link

The Gunicorn integration offers metrics that are not provided by Gunicorn's own statsd reporting capabilities.

Perhaps most notably, it provides gunicorn.workers which gauges the worker processes and attempts to to tag them as busy if their CPU times (measured with psutil) change over a 0.1 second interval; otherwise it tags them as idle.

If a worker is blocking on non-block device I/O (say, using requests to query another API; querying a database; etc.) before and after the check interval, the worker will be tagged as idle but I believe a user would expect this to be tagged as busy.

This was trivial to induce on a container running python:3.9-slim and using two flask apps: one which made requests to the other, which would sleep for 200ms. I was able to reproduce it with sync and gthread workers.

I want to recognize that what this integration is trying to do is quite difficult given what Gunicorn provides, but I wish either of the following were provided instead:

  • tag names and documentation that don't give the impression that this integration can gauge worker saturation for all workloads: it's probably only viable for only services that can consistently respond in <100ms.
  • the quite substantial work required to monkeypatch Gunicorn and provide a more correct approximation. Without this, the Gunicorn integration provides no value to the projects I work on.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant