litellm/litellm-rust/crates
Yujong Lee 0da3f6b72a feat(core): process-wide in-flight limit for provider calls
Without a limit, every host call becomes an in-flight upstream request
with an unbounded response buffer: a burst of N concurrent calls means N
open provider sockets, N buffered bodies in memory, and a provider-side
429 storm. reqwest pools cap only idle sockets, the router is a pure
selector, and the axum entrypoint has no tower limits, so nothing bounds
this today.

- core: new concurrency module. Hosts resolve the config-shaped env at
  startup and install a process-wide semaphore via init_limits
  (uninitialized = unlimited, so rollouts keep today's behavior).
  acquire() is an OwnedSemaphorePermit held across the whole call,
  including response buffering (that buffering is the memory being
  capped); queue mode is FIFO and cancel-safe (dropping the future
  releases nothing it did not hold), shed mode fails fast with a new
  Error::Overloaded before any provider call.
- core entrypoints messages, chat_completions, audio_transcription hold
  the permit for the call; the gateway OCR handler acquires it too
  (interim until the handler moves into core). Streaming entrypoints are
  not capped yet: their in-flight window outlives the call that started
  them, so the permit belongs on the returned stream (follow-up once the
  frame-stream route lands).
- errors: Error::Overloaded maps to RustBridgeDeclined in both bridge
  mappers (nothing reached the provider; the Python host may fall back
  to its own path) and to 429 in the gateway.
- hosts: the bridge module init and the gateway main read
  LITELLM_RUST_MAX_IN_FLIGHT and LITELLM_RUST_SHED_ON_LIMIT (invalid
  values warn and are ignored); the bridge also applies
  LITELLM_RUST_WORKER_THREADS to the shared runtime, which must happen
  at module init because pyo3-async-runtimes builds the runtime lazily
  and cannot resize it afterwards.
- diagnostics: new native_stats() beside gil_stats() reporting
  max_in_flight, in_flight, and shed_on_limit.
2026-09-03 09:28:59 -07:00
..
ai-gateway feat(core): process-wide in-flight limit for provider calls 2026-09-03 09:28:59 -07:00
CODING_STANDARDS refactor(rust): extract domain-neutral Python interop 2026-09-02 12:16:26 -07:00
core feat(core): process-wide in-flight limit for provider calls 2026-09-03 09:28:59 -07:00
python-bridge feat(core): process-wide in-flight limit for provider calls 2026-09-03 09:28:59 -07:00
python-interop fix(python-bridge): harden sync and async route boundaries (#39332) 2026-09-02 16:26:35 -07:00