High-Throughput LLM Inference: Engineering Practices for Stable Token Rates

    This article breaks down how large language model inference throughput is determined and how to keep it predictable under high concurrency. It explains prefill versus decode bottlenecks, the trade-offs among batching, KV cache memory, and concurrency, and the specific demands of coding workloads such as prefix reuse, speculative decoding, and tiered routing. It also covers observability and load-testing methods, elastic scheduling and graceful degradation, and a practical checklist for client-side integration. The key takeaway is that LLM serving performance is a range rather than a constant, and reliability comes from aligning workload shape, batching strategy, cache budget, and elasticity so the high-traffic lower bound stays usable.

    1. From Peak Rate to Stable Throughput: The Real Problem

    A model service provider recently published a set of performance figures: generation rates of roughly 200 tokens per second under light load, and 70–80 tokens per second sustained during business peaks. For developers, the value of numbers like these is not “how high can it go,” but whether the service is still usable in the worst case. A service that only performs well during idle periods can hit queuing, timeouts, and retry storms as soon as a weekday daytime or a release window arrives. This article therefore frames the topic as a general engineering problem: how to obtain predictable, capacity-plannable inference throughput in high-concurrency coding scenarios.

    2. What Determines Token Rate

    Generation rate is usually split into two parts: time to first token (TTFT) and the per-token output rate afterward (TPOT). TTFT is mainly affected by input length, scheduling queue time, and prefill compute; TPOT is mainly affected by the size of the weights and cache that must be moved at each decoding step. Understanding this explains why “the same model” can feel dramatically different across input shapes.

    • Prefill phase: compute-bound; the longer the input, the slower the first token.
    • Decode phase: memory-bandwidth-bound; the higher the concurrency, the more easily per-request rate is diluted.
    • Queueing phase: once concurrency exceeds service capacity, latency growth is often non-linear.

    3. The Triangle of Batching, GPU Memory, and Concurrency

    The server side must trade throughput against latency. Static batching is simple to implement but prone to head-of-line blocking, where short requests wait behind long ones. Continuous batching lets requests enter and leave the batch dynamically at each step, substantially improving GPU utilization; this is one of the key engineering techniques that keeps a usable rate available during peaks.

    At the same time, the key-value cache (KV Cache) grows linearly with concurrency and context length and quickly becomes the memory bottleneck. Common mitigations in the industry include paged cache management, quantization-based compression, prefix reuse (turning the system prompt and repository context into a reusable prefix), and tiered caching for very long sessions.

    An illustrative capacity estimation (pseudocode, conveying the idea only):

    1. # Estimate per-GPU concurrency: memory budget / per-session cache usage
    2. kv_per_token = layers * 2 * kv_heads * head_dim * bytes_per_elem
    3. cache_budget = total_gpu_mem * 0.6 # reserve room for weights and activations
    4. max_tokens_in_flight = cache_budget // kv_per_token
    5. max_concurrency = max_tokens_in_flight // avg_context_len

    4. What Makes Coding Workloads Different

    The load generated by AI coding tools differs markedly from traditional chat: the input side carries large blocks of code and multi-turn tool-call results, the output side demands low-latency continuous completion, and requests are clearly bursty (a single save can trigger multiple completions). This points to three optimization directions:

    1. Prefix reuse: a shared prefix from the same repository and prompt template is computed only once.
    2. Speculative decoding: a small model drafts and a large model verifies, raising output rate while preserving quality.
    3. Tiered routing: completion requests go to a low-latency queue, while refactoring and generation requests go to a high-throughput queue.

    5. Observability and Load Testing

    Do not look at averages alone. Collect TTFT P50/P95/P99, the TPOT distribution, queue time, cache hit rate, and rejection rate, then apply stepped load with a fixed corpus to find the knee where throughput starts to collapse. Example:

    1. metrics = {"ttft_p95": [], "tpot_p50": [], "queue_ms": []}
    2. for conc in [8, 16, 32, 64, 128]:
    3. r = run_load_test(concurrency=conc, prompt_set="code_completion")
    4. metrics["ttft_p95"].append(r.ttft_p95)
    5. metrics["tpot_p50"].append(r.tpot_p50)
    6. metrics["queue_ms"].append(r.queue_ms)
    7. # Knee: the concurrency level where P95 latency starts rising super-linearly

    6. Elastic Scheduling and Degradation

    Peak protection usually relies on a combination of measures: autoscaling based on queue length, request priority and quotas, timeouts with backoff retries, and controlled degradation (shortening context, disabling non-essential tool calls, switching to a smaller model). In public cloud, these capabilities are typically provided by general categories such as container platforms, load balancers, message queues, logging services, and monitoring and alerting, with scaling decisions driven by standard metrics rather than any single proprietary interface.

    7. Client-Side Integration Checklist

    • Use streaming output to improve perceived experience; the faster the first token, the smoother it feels.
    • Set sensible client timeouts and idempotent retries to avoid retry amplification.
    • Split long context into retrieval snippets to control per-request input size.
    • Apply local rate limiting and queueing to smooth out peaks and fill valleys.
    • Maintain a dual “rate–quality” regression suite so throughput is never traded for availability.

    8. Conclusion

    Ranges like “200 at low load, 70–80 at peak” show that LLM service performance is a range, not a constant. What engineering can actually control is aligning workload shape, batching strategy, cache budget, and elasticity so that the peak lower bound stays stable within a usable range. Only then can a coding assistant move from “works in a demo” to “reliable in production.”