-
Notifications
You must be signed in to change notification settings - Fork 615
[FEATURE]: Granian feature requests - max-requests, jitter, and worker lifecycle improvements #2358
Copy link
Copy link
Open
Open
Feature
Copy link
Labels
SHOULDP2: Important but not vital; high-value items that are not crucial for the immediate releaseP2: Important but not vital; high-value items that are not crucial for the immediate releaseenhancementNew feature or requestNew feature or requestperformancePerformance related itemsPerformance related itemspythonPython / backend development (FastAPI)Python / backend development (FastAPI)
Milestone
Description
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:app2. --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:app3. --graceful-timeout for worker shutdown
Gunicorn equivalent: --graceful-timeout
Granian has --workers-kill-timeout but clearer graceful shutdown semantics would help.
Context
- Related to SSE connection leak issue: [BUG]: (sse): Granian CPU spikes to 800% after load stops, recovers when load resumes #2357
- Granian upstream issue: Disconnect event is not propogated to the middleware while a request is processing emmett-framework/granian#286
- These features would help work around granian not properly closing SSE connections after client disconnect
References
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
SHOULDP2: Important but not vital; high-value items that are not crucial for the immediate releaseP2: Important but not vital; high-value items that are not crucial for the immediate releaseenhancementNew feature or requestNew feature or requestperformancePerformance related itemsPerformance related itemspythonPython / backend development (FastAPI)Python / backend development (FastAPI)