bedkillerspacex-boop/codex-skill-library/uvicorn-gunicorn-workers
Claude Code and agent skill by bedkillerspacex-boop/codex-skill-library
Trust tier 3
- community
Source check pending
Checking that the SKILL.md file is still in the repository.
Size and run Uvicorn/Gunicorn workers for owned Python ASGI apps: worker classes, counts vs CPU, timeouts, keepalive, graceful reload, memory limits, and health checks. Use when tuning FastAPI/Starlette deployments — not for attacking third-party services.
Install
npx vskill@latest install bedkillerspacex-boop/codex-skill-library/uvicorn-gunicorn-workersSKILL.md
The same SKILL.md was published earlier as bedkillerspacex-boop/codex-skill-library/uvicorn-gunicorn-workers.
Uvicorn / Gunicorn Worker Sizing
Scope And Authorization
- In scope: Process model tuning for ASGI apps you operate (Uvicorn, Gunicorn+UvicornWorker, Hypercorn).
- Out of scope: Load testing third-party sites without authorization.
- Change worker counts in staging first; watch memory before production scale-out.
- Pair with observability skills and
code-quality-standards.
When To Use
- Choosing between pure Uvicorn multi-process vs Gunicorn managing UvicornWorkers.
- High latency/timeouts, OOM kills, or uneven CPU under load.
- Setting
timeout,graceful_timeout,keep-alive,limit_concurrency. - Container CPU/memory requests aligned to worker math.
Do Not Use As Primary
| Need | Skill instead | |
|---|---|---|
| App-level auth/security review | web security skills | |
| Reverse proxy caching | varnish-vcl-basics / CDN skills | |
| vLLM GPU serving | vllm-serving-hardening | |
| Generic observability | observability-metrics-tracing | |
| Implementation quality baseline | code-quality-standards |
Domain Focus
| Setting | Guidance | |
|---|---|---|
| Worker class | uvicorn.workers.UvicornWorker under Gunicorn for ASGI | |
| Worker count | Start ~ (2 x CPU) + 1 for sync-ish; for async often fewer (1–2 per core) + concurrency limits | |
| Threads | Prefer async concurrency over many threads for pure ASGI | |
| Timeout | ≥ longest expected request; smaller than LB idle timeout carefully | |
| Max requests | Recycle workers to mitigate leaks (max_requests + jitter) | |
| Pitfalls | Too many workers × large models = OOM; blocking CPU work in async handlers |
Process Topology
| Mode | Command sketch | Notes | |
|---|---|---|---|
| Uvicorn only | uvicorn app:app --host 0.0.0.0 --port 8000 --workers N | Simple | |
| Gunicorn+Uvicorn | gunicorn app:app -k uvicorn.workers.UvicornWorker -w N | Better process mgmt | |
| Single worker + concurrency | --workers 1 --limit-concurrency C | High async I/O |
Workflow
1. Confirm scope and success criteria
- Record app type (I/O bound vs CPU), container CPU/memory, SLOs (p95 latency, error rate).
- Success: stable p95 under target RPS; no OOM; clean rolling deploys; health checks pass.
- Rollback: previous worker env vars / deployment revision.
2. Inventory current runtime
- Note blocking libraries (PDF, numpy heavy) inside request path.
- Check proxy timeouts (nginx/ALB) vs app timeout.
3. Baseline metrics
- Under representative load: CPU, RSS per worker, event loop lag, queue time.
- Capture 5xx rate and timeout count.
- Measure startup time × worker count (deploy readiness).
4. Apply sizing changes
Gunicorn config example:
Uvicorn CLI:
- Align K8s
resources.limits.memory≥workers × peak_rss × headroom. - Move CPU-heavy work to task queue; keep request path async I/O.
- Use separate deployment for WebSockets if sticky sessions / long lived connections differ.
- Prefer graceful shutdown: handle SIGTERM, stop accepting, drain.
5. Verify with evidence
- Rolling update: readiness fails until workers listen.
- Kill -TERM master: connections drain within graceful_timeout.
- Memory: scale workers until OOM then back off one.
6. Observe and harden
- Metrics: request duration, in-flight, worker restarts, RSS.
- Alert on restart loops and timeout ratio.
- Revisit after traffic shape changes (batch uploads vs chatty API).
7. Hand off
- Document
WEB_CONCURRENCYformula for the service. - Runbook: OOM → reduce workers / raise memory / find leak.
- Apply
code-quality-standardsto app code causing blocks.
Good / Bad
| Topic | Good | Bad | |
|---|---|---|---|
| Workers | Match CPU + memory budget | workers=32 in 512Mi pod | |
| Async | Non-blocking I/O | time.sleep / heavy CPU in handler | |
| Timeouts | App < proxy idle with margin | Default 30s with 5min uploads | |
| Recycle | max_requests + jitter | Never recycle leaking workers | |
| Health | Cheap /health | Health hits DB every time without need |
Output Checklist
- [ ] Workload shape and CPU/mem recorded
- [ ] Topology chosen (uvicorn vs gunicorn)
- [ ] Worker count and concurrency justified
- [ ] Timeouts aligned with proxy
- [ ] Memory headroom verified under load
- [ ] Graceful shutdown tested
- [ ] Metrics/alerts in place
- [ ] Staging evidence attached
- [ ]
code-quality-standardsapplied - [ ] Residual risk noted
Rules
- Load test only owned environments.
- Prefer evidence from metrics over cargo-cult formulas alone.
- Do not hide app blocking bugs by endless worker scale-out.
- Keep secrets out of process listings and logs.
- Focus on worker sizing and process model for Uvicorn/Gunicorn.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckinguvicorn-gunicorn-workers/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/bedkillerspacex-boop/codex-skill-library/uvicorn-gunicorn-workers)