Large-Scale LLM Inference Deployment: A Practical Guide to Latency, Cost, and Reliability

    This guide explains how to deploy large-scale online LLM inference by treating capability limits and cost limits as separate problems. It covers defining four fixed metrics (time to first token, per-token output latency, end-to-end P95/P99 latency, and cost per million tokens), layered compute and parallelism design, KV cache as the real concurrency bottleneck, continuous batching and request governance, elastic scaling and release strategy, observability, and a final deployment checklist. Readers will learn a tuning order that fixes queueing and batching before caching, quantization, or adding machines.

    1. Problem Definition: Capability Limits vs. Cost Limits

    The model itself sets the upper bound on capability, but user experience and commercial viability are determined by cost per request, tail latency, and availability. The hard part of large-scale online inference is not getting a model to run. It is making three things true at the same time: latency stays controlled under high concurrency, GPU memory and compute utilization are high enough, and the system self-heals during failures and traffic spikes.

    When evaluating a deployment approach, fix four metrics so results are comparable: time to first token, per-token output latency, end-to-end latency percentiles (especially P95/P99), and total cost per million tokens. Average latency alone hides queueing problems; throughput alone hides user experience problems.

    2. Layered Design of Compute and Parallelism

    Inference and training have completely different resource profiles: training is compute-intensive and tolerates long runtimes, while inference is memory-bandwidth-intensive and sensitive to queueing. Layered design means splitting different workloads into different resource pools.

    • Interactive short requests: optimize for low latency with small batches and high-clock instances, and minimize cross-node communication.
    • Long-context and batch offline jobs: optimize for throughput with larger batches and more aggressive parallel splitting, allowing responses in seconds or even minutes.

    For parallelism, a common industry combination is tensor parallelism to reduce per-layer compute and memory pressure, pipeline parallelism to split layers, and data parallelism to scale replicas horizontally. The rule of thumb: if a single machine’s memory can hold the weights plus a minimal usable KV cache, do not split across machines, because cross-node communication directly raises tail latency. Introduce cross-node parallelism only when a single replica cannot fit or when higher throughput is required.

    An illustrative way to organize startup parameters (showing configuration structure only, not a specific implementation):

    1. replica:
    2. tensor_parallel: 2 # Split within one machine over high-speed interconnect
    3. pipeline_parallel: 1 # Leave off when possible
    4. max_batch_tokens: 32768 # Per-batch token budget to control queueing and memory
    5. kv_cache_dtype: fp8 # Reduce cache footprint
    6. gpu_memory_utilization: 0.88

    3. GPU Memory and Caching: The Real Concurrency Bottleneck

    The concurrency ceiling of an online service is often not compute but the KV cache. Three general techniques deliver the clearest gains:

    1. Paged cache management. Splitting the cache into fixed-size blocks allocated on demand significantly reduces fragmentation and can increase effective concurrency several times over.
    2. Prefix reuse. System prompts, few-shot examples, and long documents repeat heavily across requests; hitting a prefix cache lowers both time to first token and compute consumption.
    3. Quantization and low-precision caches. Using lower-precision weights and caches within an acceptable accuracy range is the most direct way to increase per-GPU capacity.

    Quantization carries accuracy and stability risks, so build an offline evaluation set for regression testing and keep the ability to roll back to a high-precision configuration in one step.

    4. Scheduling: Continuous Batching and Request Governance

    Static batching causes head-of-line blocking, where short requests wait behind long ones. Continuous batching lets new requests join dynamically at each decoding step and lets completed sequences exit immediately, keeping GPU utilization high.

    Request governance is equally important:

    • Tiered queues: split by business priority to protect paid or core-path requests.
    • Length budgets: cap input and output length per request so a few extremely long requests cannot drag down an entire batch.
    • Timeouts and retries: retries must include backoff and a maximum attempt count, otherwise failures trigger a retry storm.
    • Rate limiting and degradation: apply token bucket rate limiting at the entry point, and degrade to a smaller model or return cached results under overload.

    5. Elastic Scaling and Release Strategy

    Inference traffic has clear peaks and troughs, so elasticity capability equals cost optimization capability. In practice, use “queue wait time + GPU memory level” as the scaling signal, which tracks the real bottleneck more closely than CPU utilization alone; also set a scale-in cooldown window to avoid oscillating scale up and down.

    For releases, use canary and shadow traffic: shift a small percentage of traffic first and watch percentile latency and error rate, then use mirrored traffic to validate the new version’s output quality, then ramp up gradually. Model weights are large, so distribution can rely on object storage plus node-local caching, while the container platform handles startup and readiness probe management.

    6. Observability and Continuous Tuning

    No measurement, no optimization. A minimum viable observability setup contains four data types: request-level logs (token counts, cache hit status, queue wait time), metrics monitoring (throughput, percentile latency, GPU memory usage), distributed tracing (locating time spent across components), and output quality sampling.

    Proceed through the tuning loop in this order: first fix queueing and batching parameters, then caching and quantization, and only then consider scaling out. Reversing the order leads to hiding scheduling defects by adding machines, and costs spiral quickly.

    7. Deployment Checklist

    • Are metric definitions unified, and is P99 included in the SLO?
    • Does each replica close the loop within a single machine first, avoiding unnecessary cross-machine communication?
    • Is the prefix cache hit rate monitored?
    • Are overload degradation and retry storm protection in place?
    • Do scaling signals reflect the real bottleneck?
    • Is there a fast rollback path for models and configurations?

    Implement these layers in order and run them on a cloud environment with general capabilities such as a container platform, object storage, logging, and monitoring alerts, such as Baidu AI Cloud, and you can build a large-scale inference foundation with stable latency, predictable cost, and smooth scale-out.