Skip to content

[FEATURE]: Granian feature requests - max-requests, jitter, and worker lifecycle improvements #2358

@crivetimihai

Description

@crivetimihai

Summary

Track desired granian features that exist in gunicorn but are missing in granian. These would help with SSE workloads and prevent resource leaks.

Requested Features

1. --max-requests (worker recycling after N requests)

Gunicorn equivalent: --max-requests

Restart workers after handling N requests. Useful for preventing memory leaks and clearing stale connections.

# Gunicorn
gunicorn --max-requests 10000 app:app

# Desired in Granian
granian --max-requests 10000 app:app

2. --max-requests-jitter (randomized restart timing)

Gunicorn equivalent: --max-requests-jitter

Add random jitter to --max-requests or --workers-lifetime to prevent all workers from restarting simultaneously (thundering herd).

# Gunicorn - restarts between 9000-11000 requests
gunicorn --max-requests 10000 --max-requests-jitter 1000 app:app

# Desired in Granian
granian --workers-lifetime 3600 --workers-lifetime-jitter 600 app:app
# Or
granian --max-requests 10000 --max-requests-jitter 1000 app:app

3. --graceful-timeout for worker shutdown

Gunicorn equivalent: --graceful-timeout

Granian has --workers-kill-timeout but clearer graceful shutdown semantics would help.

Context

References

Metadata

Metadata

Assignees

Labels

SHOULDP2: Important but not vital; high-value items that are not crucial for the immediate releaseenhancementNew feature or requestperformancePerformance related itemspythonPython / backend development (FastAPI)

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions