Skip to content

feat(proxy): reuse shared httpx clients instead of per-request clients (#1193)#1196

Merged
zhongwen666 merged 1 commit into
alibaba:masterfrom
zhongwen666:feat/proxy-httpx-pool-reuse-0701
Jul 1, 2026
Merged

feat(proxy): reuse shared httpx clients instead of per-request clients (#1193)#1196
zhongwen666 merged 1 commit into
alibaba:masterfrom
zhongwen666:feat/proxy-httpx-pool-reuse-0701

Conversation

@zhongwen666

Copy link
Copy Markdown
Collaborator

closes #1193

Stack 3/3 — depends on #1194 (multi-worker) and #1192's PR #1195. Merge last. Its diff auto-cleans once the parent PRs merge.

Split from the original combined proxy multi-core PR (#1147). This PR only reuses httpx clients:

  • Split the proxy into two long-lived clients: RPC (short JSON control calls) + proxy (streaming/SSE/large bodies).
  • host_proxy/http_proxy reuse the shared proxy client instead of opening/closing one per request.
  • Both closed once via aclose(), wired from the admin lifespan on shutdown.
  • Metrics tagged with worker_pid so per-worker series stay distinct.

Tests: tests/unit/sandbox/test_proxy_httpx_reuse.py, updated tests/unit/sandbox/test_proxy_enhancements.py.

Split the proxy into two long-lived httpx clients: an RPC client for short
JSON control calls and a proxy client for streaming/large bodies, both closed
once via aclose() on shutdown (wired from the admin lifespan). host_proxy and
http_proxy now reuse the shared proxy client instead of opening and closing a
client per request, reusing pooled connections. Tag metrics with worker_pid
so per-worker series stay distinct.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@zhongwen666 zhongwen666 force-pushed the feat/proxy-httpx-pool-reuse-0701 branch from 46f22d9 to c5e52fb Compare July 1, 2026 08:42
@xieyang0827 xieyang0827 self-requested a review July 1, 2026 09:34
@zhongwen666 zhongwen666 merged commit 4166037 into alibaba:master Jul 1, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Reuse shared httpx clients in proxy instead of per-request clients

2 participants