Hey team! 👋
We're seeing intermittent long delays (~250s) on some async LLM calls and think it might be related to HTTP connection pooling. Looking for guidance!
Setup:
- Using BAML async client in Python
- Total: 100-1000 concurrent requests to the same provider (OpenRouter)
- Each per-document batch uses its own semaphore for concurrency control
The Issue:
- Random 1-4 chunks (out of 100s of chunks per document) take 240-250 seconds
- BAML's function_log.timing.duration_ms shows 249447ms
- Low input/output tokens, not atypical workload.
- Provider's metrics show these requests completed quickly on their end
- Our Python process was alive (lock renewals every 30s confirmed)
- Other chunks complete normally in 2-5 seconds
What we've ruled out:
- ✅ Not provider backend latency (their metrics disagree with BAML's timing)
- ✅ Not Python/asyncio blocking (other chunks complete fine concurrently)
- ✅ BAML timeouts configured:
connect_timeout_ms: 10000,
time_to_first_token_timeout_ms: 60000,
idle_timeout_ms: 30000
- ✅ Started happening ~1-2 months ago (Nov 2025). My theory is moving to single provider is exhausting the pool.
Questions:
1. Does BAML expose HTTP connection pool configuration? I saw some chatter on GH issues.
3. What's the recommended max concurrent calls to the same provider? I think we startd seeing this when we moved the waterfall to single provider (OpenRouter)
4. Any way to log/get visibility into HTTP connection pool utilization?
Would love any insights or suggestions! Happy to provide more logs/traces. Thanks! 🙏