Skip to content

SGPINF-961: fix: reduce HTTPX connection limits to add backpressure#144

Merged
sayakmaity merged 1 commit intomainfrom
fix/reduce-httpx-connection-limits
Feb 5, 2026
Merged

SGPINF-961: fix: reduce HTTPX connection limits to add backpressure#144
sayakmaity merged 1 commit intomainfrom
fix/reduce-httpx-connection-limits

Conversation

@sayakmaity
Copy link
Contributor

Summary

  • Make HTTPX connection pool limits configurable via HTTPX_MAX_CONNECTIONS (default: 200) and HTTPX_MAX_KEEPALIVE_CONNECTIONS (default: 100) env vars, down from hardcoded 1000/1000
  • Excess requests now queue at the HTTPX pool level instead of flooding agent pods, which then all hit OpenAI and trigger rate limits (ServiceUnavailableError + 9-15s latency)
  • Enhanced client creation log messages to include configured connection limits for observability

Test plan

  • cd agentex && make test passes
  • Deploy to dev, confirm agentex functions correctly with lower limits
  • Load test with 500 concurrent users: fewer concurrent OpenAI calls, fewer rate limit errors
  • Verify limits are overridable by setting HTTPX_MAX_CONNECTIONS / HTTPX_MAX_KEEPALIVE_CONNECTIONS env vars

Lower HTTPX connection pool limits from 1000 to configurable defaults
(200 max connections, 100 max keepalive) to prevent flooding agent pods
with concurrent requests during high load. Excess requests now queue at
the pool level instead of all hitting OpenAI simultaneously.
@sayakmaity sayakmaity requested a review from a team as a code owner February 5, 2026 20:31
sayakmaity added a commit to scaleapi/scale-agentex-python that referenced this pull request Feb 5, 2026
- Add `num_retries=3` default to LLMConfig so litellm retries on OpenAI
  429 rate limit errors with built-in exponential backoff
- Increase Temporal DEFAULT_RETRY_POLICY from 1 attempt (no retries) to
  3 attempts with exponential backoff (1s, 2s, 4s... up to 30s)

This complements the HTTPX connection limit reduction in agentex backend
(scaleapi/scale-agentex#144) to address OpenAI rate limiting under high
concurrent load.
@sayakmaity sayakmaity merged commit f436743 into main Feb 5, 2026
27 checks passed
@sayakmaity sayakmaity deleted the fix/reduce-httpx-connection-limits branch February 5, 2026 21:51
@sayakmaity sayakmaity changed the title fix: reduce HTTPX connection limits to add backpressure SGPINF-961: fix: reduce HTTPX connection limits to add backpressure Feb 6, 2026
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.

2 participants