gunicorn_worker_healthcheck
HTTP endpoint that counts ready gunicorn workers
When using the default sync gunicorn worker, using an HTTP endpoint of the application itself
(i.e. that is also handled by the same mechanism, namely the gunicorn workers, as normal application traffic)
to check whether the application is able to handle traffic
(and to e.g. remove it from the load balancing rotation on failure)
can lead to negative feedback loops in high load situations:
The workers may become so backed up with application requests that they are unable to respond to the healthcheck requests in a timely manner. Thus, this application is removed from serving traffic, leaving even less applications to serve the incoming traffic, thus increasing the chance that they, too, will become backed up -- repeat until no applications are available for serving traffic at all.
This package provides an alternative healthcheck endpoint that a) is served by a separate thread, independent of the main application traffic b) only checks whether the application and gunicorn startup process has completed (i.e. any/all gunicorn worker processes have reported to be ready).
Usage
Put this into your config file (usually gunicorn.conf.py):
import gunicorn_worker_healthcheck
healthcheck_bind = '127.0.0.1:8001'
gunicorn_worker_healthcheck.start(globals())
This starts an HTTP server in a thread;
on request it counts the number of workers that have notified they are ready
(using the post_worker_init hook to write a pid file).
If the required number of workers are ready, it returns HTTP 200, else 500.
Configuration
healthcheck_bindhost:port on which to listen for healthcheck requests (default: None, i.e. healthcheck is disabled)healthcheck_require_workerscount of workers that must be ready for the healthcheck to report success (default: 1)healthcheck_directorydirectory in which to store the state files, one per worker (default:'', i.e. the current directory)healthcheck_filenameformat string how to name the state files, must contain one placeholder{}for the pid (default:'.gunicorn.worker.{}')
gunicorn_worker_healthcheck Changes
1.0.0 (2023-05-19)
- Initial release (initial)
Metadata
Release files for gunicorn_worker_healthcheck 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gunicorn_worker_healthcheck-1.0.0.tar.gz | 4.4 kB | Without provenance | Details for gunicorn_worker_healthcheck-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gunicorn_worker_healthcheck-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for gunicorn_worker_healthcheck-1.0.0-py3-none-any.whl |
Total release size: 10.4 kB
Release files / gunicorn_worker_healthcheck-1.0.0.tar.gz
| Download URL | gunicorn_worker_healthcheck-1.0.0.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a790b0debd57852997aa4004fe25820153f689d1e1fdcf75db9990a8b63b1e7a
|
|
BLAKE2b-256 checksum How to use checksums |
36b2d430afd38117b9f7c2ba834c15b8f0a06dc367bfaa47c38bc99637ab11bf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.24.0
|
Release files / gunicorn_worker_healthcheck-1.0.0-py3-none-any.whl
| Download URL | gunicorn_worker_healthcheck-1.0.0-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
47cdc976e3f8f4a33f65a6e4458c9753807f16c8139f39402cc4690f55e18fb6
|
|
BLAKE2b-256 checksum How to use checksums |
1fed561f42323df261edb6c84e3ec545813ff9d0c20b67d941c76c6e7278431a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.24.0
|
Security for gunicorn_worker_healthcheck 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.