Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Hugging Face 8 min read Case study mediumAdept

Efficient Request Queueing – Optimizing LLM Performance

Putting a gateway ("LLM-Server") in front of vLLM or TGI with per-user, per-model queues and round-robin scheduling keeps power users from starving others, which the engine's FIFO queue cannot do once requests reach it. Because vLLM doesn't cap its queue length, the gateway polls vLLM's Prometheus /metrics and only dispatches while the backend queue is below a small target (e.g. 3) and time-per-output-token stays under ~150ms. That target trades latency for new users against batch utilization. vLLM's newer priority scheduling can replace some of this logic, but a gateway is still needed to assign priorities and control the dispatch rate.

Assumes: LLM inference basicscontinuous batchingPrometheus metrics

Related posts

  • How Long Prompts Block Other Requests - Optimizing LLM Performance

    Hugging Face hardMaster

    Under vLLM's default chunked-prefill scheduling, a single long prompt blocks the prefill queue, and any prefill running alongside decodes slows token generation for requests already in progress. The queue-blocking problem is largely solved by vLLM's newer parallel partial prefills, which batch several requests' prefills while capping how many long prompts run concurrently, cutting time-to-first-token for short requests. The decode slowdown is more fundamental. TNG compares three mitigations from running 24 H100s: deprioritizing long prompts, routing them to a separate server, and disaggregated prefill. Disaggregated prefill isolates decodes best but needs a second full deployment, leaves GPUs unevenly utilized, and is still experimental in vLLM.

  • Prefill and Decode for Concurrent Requests - Optimizing LLM Performance

    Hugging Face mediumAdept

    LLM token generation splits into a compute-bound prefill phase, which processes all prompt tokens in parallel to produce the first token, and a memory-bandwidth-bound decode phase, which produces later tokens one at a time. These map to time to first token and time per output token. Static batching leaves the GPU underutilized and delays new requests. Prefill-first continuous batching (vLLM, TGI) minimizes time to first token but pauses running decodes. Chunked prefill interleaves prefill chunks with decode steps, trading a small time-to-first-token increase for smoother decoding. At TNG it raised total throughput by about 50%, and the default chunk size is recommended when load patterns are unpredictable.

  • Autoscaling endpoints for LLM inference

    Together AI mediumAdept

    LLM serving breaks classic autoscaling assumptions. GPU utilization misrepresents load, and multi-minute cold starts mean scaling has to act on leading signals. Together AI's dedicated endpoints scale proportionally (ceil(N × observed/target)) on inference-native metrics such as in-flight requests, TTFT, GPU or token utilization, and throughput, with an eager scale-up window and a patient scale-down window to avoid sawtooth cold starts. In a replayed sine-plus-spike load on Qwen3.5-9B/H100, only inflight_requests (target 8) triggered scaling. TTFT p95 and GPU utilization policies never fired despite 3–5s client p95, because continuous batching hides queue pressure from first-token latency. Measured cold starts of roughly 1.5–2.5 minutes argue for keeping min_replicas headroom on SLO-bound endpoints.

  • ThunderAgent: 2x Faster Agentic Inference for Synthetic Data Generation at Scale

    Together AI hardMaster

    ThunderAgent is a scheduling layer between agent clients and inference backends that treats each multi-turn agentic workflow as a schedulable program instead of independent requests, preventing KV cache thrashing when agents pause for tool calls. Under memory pressure it pauses low-priority programs to raise cache hit rates, then resumes them via a global waiting queue onto the node with the most free capacity, replacing static session pinning. On one 8×H100 node with HiCache at batch 192 it reached 803 vs 390 tokens/s for SGLang, with mean latency cut from 65s to 10.6s. Across 2 to 8 nodes it scaled near-linearly and outperformed SGLang Gateway by up to 2.39×, requiring only a program_id field on OpenAI-compatible requests.

  • Boost your throughput with dynamic batching

    Modal mediumAdept

    Modal added a `@modal.batched()` decorator that groups incoming requests into batches flushed when either `max_batch_size` is reached or `wait_ms` elapses, avoiding the unbounded waits of fixed-size batching. Batching helps GPU inference because model weights (over 6 GB for Whisper large v3) must be moved from memory to compute units per pass, and inference is usually memory-bandwidth bound. On an A10G, batching Whisper with a max batch size of 64 raised throughput from about 1.2 to 3.3 requests per second per container, cutting inference cost by roughly 65%. The function only needs to accept and return lists.

The quest for software engineering knowledge.

Look:
Layout: