Run one uvicorn worker instead of two #146

Merged
CrowderSoup merged 1 commit from claude/one-web-worker into main 2026-12-01 22:43:58 +00:00
Owner

Follow-up to #144. Drops the web role from two uvicorn workers to one.

Why

After #144, the measured savings were smaller than expected: ~26 MB PSS locally (287 → 261 MB), plus the old mcp container's uv run wrapper on the droplet. uvicorn starts extra workers with spawn, so each one loads its own full copy of Django and the MCP server (~115 MB each). Gunicorn's forked workers shared most of that memory.

One ASGI process already runs requests side by side (async, with sync views and MCP tools on threads), and vTodo serves a few requests a minute. With one worker, uvicorn also skips its supervisor and the multiprocessing resource tracker.

Change

  • Dockerfile: WEB_WORKERS defaults to 1.
  • README.md and the DB pool comment in config/settings.py now say 1.

WEB_WORKERS=2 in the env brings the second worker back if it's ever needed.

After deploying

Check docker stats for vtodo-web, and compare latency in the kamal-proxy logs against the numbers from #144 (POST /mcp p50 34 ms; /api/v1/tasks/ p50 ~59 ms).

🤖 Generated with Claude Code

Follow-up to #144. Drops the web role from two uvicorn workers to one. ## Why After #144, the measured savings were smaller than expected: ~26 MB PSS locally (287 → 261 MB), plus the old mcp container's `uv run` wrapper on the droplet. uvicorn starts extra workers with `spawn`, so each one loads its own full copy of Django and the MCP server (~115 MB each). Gunicorn's forked workers shared most of that memory. One ASGI process already runs requests side by side (async, with sync views and MCP tools on threads), and vTodo serves a few requests a minute. With one worker, uvicorn also skips its supervisor and the multiprocessing resource tracker. ## Change - `Dockerfile`: `WEB_WORKERS` defaults to `1`. - `README.md` and the DB pool comment in `config/settings.py` now say 1. `WEB_WORKERS=2` in the env brings the second worker back if it's ever needed. ## After deploying Check `docker stats` for vtodo-web, and compare latency in the kamal-proxy logs against the numbers from #144 (`POST /mcp` p50 34 ms; `/api/v1/tasks/` p50 ~59 ms). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Run one uvicorn worker instead of two
All checks were successful
tests / pytest (push) Successful in 2m11s
da7e1b1d9a
uvicorn starts extra workers with spawn, so each loads its own copy of
Django and the MCP server (~115 MB). Gunicorn's forked workers shared
most of that. One ASGI process already serves requests side by side on
threads, and vTodo's traffic is a few requests a minute.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CrowderSoup deleted branch claude/one-web-worker 2026-12-01 22:43:58 +00:00
Sign in to join this conversation.
No description provided.