High-Concurrency LLM Inference: Optimizing Token Throughput in Production

    This article examines the technical challenges behind surging LLM API traffic and explains how to build inference services that scale. It covers key metrics such as TTFT, TPOT, and overall token throughput; a layered service architecture; core optimization techniques including continuous batching, KV cache reuse, quantization, and request scheduling; and practices for observability, capacity planning, and cost-effective deployment.

    1. The Technical Challenges Behind Surging API Traffic

    Recent industry data shows that weekly API call volumes for mainstream large language models keep climbing, with token consumption for leading models reaching staggering levels—one model’s weekly token usage alone can exceed the combined total of all other models on the list. This trend is no accident: it reflects the shift of LLMs from novelty experimentation to large-scale production deployment. Use cases such as intelligent customer service, coding assistance, document summarization, and data analysis are being deeply integrated into business systems, and every user interaction translates into one or more inference requests.

    This explosive growth puts direct pressure on inference services in three ways:

    • Throughput pressure: The total volume of tokens that must be processed per unit of time rises sharply, and serial inference on a single card or instance can no longer keep up.
    • Latency pressure: Interactive applications require controllable time-to-first-token (TTFT) and overall response time; queuing and batching strategies directly affect user experience.
    • Cost pressure: GPU compute is expensive, and the core tension is maximizing effective throughput within limited resources.

    It’s worth emphasizing that call volume is only the surface symptom. What truly determines service capacity is token throughput efficiency and resource utilization.

    2. Token Throughput: The Core Metric for Inference Services

    Before optimizing, the key metrics must be clarified. LLM inference differs from ordinary web services in that its workload unit is the token, not merely the number of requests. Common metrics include:

    • TTFT (Time To First Token): The time from sending a request to receiving the first token, which determines how responsive the interaction feels.
    • TPOT (Time Per Output Token): The average time per token during generation, which determines how smooth streaming output is.
    • Overall throughput (tokens/s): The total tokens the system can produce per unit of time—the core of capacity planning.
    • Effective compute utilization: The proportion of time the GPU actually spends computing, which indicates whether resources are idle.

    A common mistake is looking only at requests per second. Because input and output lengths vary enormously from request to request, counting only requests severely distorts the picture. Using tokens as the unified unit of measurement enables fair comparison across different workloads and different optimization approaches.

    3. Overall Architecture of a High-Concurrency Inference Service

    To support high concurrency, single-instance serial inference must be re-architected into a layered, horizontally scalable service. A typical inference service consists of the following layers:

    1. Access layer: Handles authentication, rate limiting, request routing, and protocol conversion, normalizing external requests.
    2. Scheduling layer: Maintains request queues and performs batching and priority scheduling—the key to throughput optimization.
    3. Inference execution layer: Runs model forward passes and manages GPU memory and the KV cache.
    4. Observability layer: Collects latency, throughput, GPU memory usage, queue length, and other metrics to support capacity decisions.

    Layers are decoupled through message queues or asynchronous tasks, allowing the scheduling layer to aggregate requests flexibly while the execution layer focuses on computation. Container-based auto-scaling can add instances during traffic peaks and reclaim resources during troughs, balancing performance and cost.

    4. Key Optimization Techniques

    1. Continuous Batching

    With traditional static batching, a group of requests must start and finish together, so short requests wait for long ones and compute sits idle. Continuous batching allows new requests to be inserted dynamically during generation and completed requests to be removed, keeping the GPU fully loaded at all times. The scheduling logic can be abstracted as follows:

    1. # Pseudocode: continuous batching scheduling
    2. def schedule_step(running, waiting):
    3. # 1. Remove requests that finished generating an end-of-sequence token
    4. running = [r for r in running if not r.is_finished()]
    5. # 2. Fill free slots from the waiting queue
    6. while len(running) < max_batch_size and waiting:
    7. running.append(waiting.pop(0))
    8. # 3. Run one forward step for all requests in this batch
    9. step_forward(running)
    10. return running

    This approach significantly improves GPU utilization and is a foundational capability for high-throughput services.

    2. KV Cache and Prefix Reuse

    Autoregressive generation requires caching the Key/Value tensors of historical tokens (the KV cache) to avoid redundant computation. When multiple requests share a common prefix—such as the same system prompt or few-shot examples—the same prefix KV cache can be reused, computing only the differing parts. This greatly reduces TTFT and redundant compute overhead. In practice, the KV cache also needs paged memory management to reduce fragmentation and improve memory occupancy.

    3. Quantization and Memory Optimization

    Weight quantization—compressing high-precision weights to low-bit representations—can significantly reduce memory usage, allowing larger models or bigger batches on the same hardware. Quantization requires a trade-off between precision and throughput, and is typically paired with offline evaluation to confirm that accuracy loss stays within an acceptable range.

    4. Request Scheduling and Rate Limiting

    Sound priority and rate-limiting strategies prevent overload cascades:

    • Bucket requests by input length to reduce waste caused by length variance within a batch.
    • Set maximum queue lengths and timeouts so that failing fast is preferred over indefinite waiting.
    • Apply token-bucket rate limiting at the access layer for burst traffic to protect backend stability.

    5. Observability and Capacity Planning

    Optimization cannot rely on guesswork; it must be grounded in data. Build monitoring and alerting for metrics such as:

    • Per-instance distributions of TTFT, TPOT, and throughput (focus on P95/P99, not just averages);
    • GPU memory usage and KV cache hit rate;
    • Queue length and rejection rate.

    Centralize logs in a logging service and route metrics into a monitoring and alerting system, so that when throughput drops or latency degrades, the bottleneck can be located immediately. Capacity planning should be based on historical token throughput and growth curves, combined with auto-scaling buffers, to avoid overload during peaks.

    6. Practical Implementation Recommendations

    Bringing this together, building a high-concurrency LLM inference service can follow this path:

    1. Use tokens as the unified unit of measurement and establish an accurate throughput and latency baseline first.
    2. Introduce continuous batching as the priority to quickly raise resource utilization.
    3. Layer on prefix cache reuse and quantization to squeeze more capacity out of each GPU.
    4. Build out observability and auto-scaling so the service stays stable under traffic fluctuations.
    5. Continuously load-test and tune, driving iteration with data rather than intuition.

    The sustained growth in LLM API traffic is a long-term trend. Whoever can produce higher effective token throughput at lower cost will hold the advantage in large-scale deployment. The techniques described here are industry-standard approaches, and can be implemented using general-purpose cloud capabilities such as container platforms, monitoring and alerting, logging services, and object storage—for example, those offered by Baidu AI Cloud—to build an LLM inference foundation that is both stable and economical.