feat(proxy): support production multi-worker proxy startup + CLI/env tuning#279
Open
Kayzo wants to merge 2 commits intochopratejas:mainfrom
Open
feat(proxy): support production multi-worker proxy startup + CLI/env tuning#279Kayzo wants to merge 2 commits intochopratejas:mainfrom
Kayzo wants to merge 2 commits intochopratejas:mainfrom
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Owner
|
Fantastic work, @Kayzo - thank you - There seems to be a linting error - can you help fix that? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds first-class support for running the Headroom proxy with multiple Uvicorn workers through the official headroom proxy CLI and the Docker image, so Headroom can be used as a shared local proxy for multi-session / multi-subagent
coding-agent setups without needing a custom launcher.
This was requested in the issue that proposed CLI flags + env vars for workers and connection pool sizing on headroom proxy, and documented the workaround of running a separate ASGI launcher under python -m uvicorn.
Motivation
Running Headroom as a shared proxy in front of multiple agent sessions (Codex/OpenAI, Anthropic, Gemini) is CPU-bound during compression/tokenization. With a single worker, the proxy can bottleneck even when the host has many cores and RAM
available.
Before this PR:
Changes
headroom/cli/proxy.py
headroom/proxy/server.py
This means in multi-worker mode, each Uvicorn worker process re-creates the exact same Headroom app with the exact same ProxyConfig used by the parent CLI process.
headroom/proxy/loopback_guard.py
which returns False for mapped literals.
Tests
tests/test_cli_proxy_env.py::test_production_scaling_cli_flags_override_env_vars:
Backwards compatibility
Docker / production usage
Verified locally: built the image from this branch with the runtime stage; container boots workers=2, shows two real child processes, and serves /health from both workers. Banner reports the configured values:
Caveats
Known behavior in multi-worker mode, not a regression from this PR but worth calling out for users:
Validation