LLM Inference Performance Bottlenecks: How to Handle Compute Shortages

    This article explains why LLM and AI coding services slow down or throttle access when inference compute is saturated, and what developers can do about it. It breaks down the two metrics that shape user experience, TTFT (time to first token) and TPS (tokens per second), and shows how the prefill and decode phases contribute to total latency. You will find a practical four-layer optimization approach: model tiering and routing, scenario-based scheduling of high and low reasoning modes, context engineering to reduce TTFT, and common service-side techniques such as continuous batching, KV Cache reuse, quantization, and elastic scaling. It also covers how to instrument client-side metrics and use P50/P95 percentiles to distinguish isolated slow requests from cluster-wide capacity pressure.

    1. The Real Issue: Compute Shortage Is Not About Access, It Is About Throughput

    Recently, several AI coding tools and LLM services have paused paid subscriptions or introduced waiting queues. On the surface, this looks like a supply-side business decision. From a technical perspective, however, the root cause is that the available compute of the inference cluster is saturated by instantaneous concurrency. To protect response quality for existing requests, providers deliberately reduce inbound traffic.

    For developers, whether a subscription is purchasable matters less than two metrics that directly determine experience:

    • TTFT (Time To First Token): The time from sending a request to receiving the first output token. It drives the feeling of lag.
    • TPS (Tokens Per Second): The streaming output speed after the first token. It drives the feeling of waiting.

    The complaint that “overthinking has eased but output is still slow” maps cleanly to an engineering reality: reasoning modes (High/Low) mainly affect the length of the reasoning chain, and therefore TTFT and total time; low TPS is constrained more by model size per single decode, batching strategy, and memory bandwidth. The two need to be addressed separately.

    2. Why a “Higher-Compute Model” Can Be Slower: Cost Breakdown of a Single Inference

    Many developers hold a common misconception: a larger model must be stronger, so the most capable model should be the default. During periods of compute scarcity, this intuition often degrades the experience.

    The latency of a single online inference can be roughly split into two parts:

    1. Total time ≈ TTFT (Prefill phase) + Output tokens / TPS (Decode phase)
    • Prefill phase: The model must “read” the entire input context at once, and computational complexity scales strongly with input length. The longer the context and the more complex the system prompt, the higher the TTFT.
    • Decode phase: Autoregressive generation token by token, constrained by memory bandwidth and concurrent batch size. The higher the concurrency, the less compute each request receives, and the more easily TPS drops.

    As a result, a model with more parameters and deeper reasoning has a naturally higher TTFT on long-context and complex reasoning tasks. If the task does not actually require that much reasoning, you are trading ten times the wait for a marginal gain in answer quality. Choosing a model that is “good enough” is a performance optimization during compute shortages, not a compromise.

    3. Four Actionable Optimization Layers

    3.1 Model Tiering and Routing: Spend Compute Where It Matters

    Building a mapping from “task difficulty” to “model tier” delivers the highest return. Route by task type:

    Task type Recommended tier Reason
    Code completion, formatting, small single-file edits Light Sensitive to TTFT, needs instant feedback
    Cross-file refactoring, unit test generation Medium Requires a degree of context understanding
    Architecture design, hard bug localization Heavy / deep reasoning Tolerates high latency, prioritizes correctness

    Illustrative routing logic:

    1. def route(task):
    2. if task.tokens_in < 2000 and task.type in ("completion", "format"):
    3. return "light" # latency first
    4. if task.type in ("refactor", "test_gen"):
    5. return "medium" # balanced
    6. return "deep" # complex reasoning, high TTFT allowed

    3.2 Scenario-Based Scheduling of High and Low Reasoning Modes

    The common “deep thinking / fast response” dual-mode design lets callers explicitly control the reasoning chain budget. Practical guidance:

    • Default to low mode: Everyday Q&A, code explanation, and simple rewrites, avoiding unnecessary overthinking.
    • Switch to high mode only on verifiable hard problems: Such as complex algorithm derivations and subtle concurrency defect analysis.
    • Set timeouts and fallback for high mode: Once the expected TTFT threshold is exceeded, automatically fall back to low mode and notify the user, avoiding long idle waits.

    3.3 Context Engineering: Directly Lower TTFT

    TTFT is highly sensitive to input length, so compressing the input is a highly cost-effective optimization:

    • Trim the system prompt and remove instructions unrelated to the current task;
    • Use retrieval augmentation to inject only relevant code snippets rather than the entire repository;
    • Apply rolling summaries to long conversations, keeping conclusions and discarding the process;
    • Constrain output structure (for example, require a patch diff instead of a full code block) to reduce output tokens and improve overall completion time.

    3.4 Common Service-Side Techniques

    If your team can self-host or run inference privately, consider industry-standard approaches: continuous batching to improve concurrent throughput, KV Cache reuse to reduce repeated prefill overhead, tensor parallelism and quantization to reduce memory pressure, request peak shaving through object storage and message queues, elastic scaling via container platforms, and dashboards plus threshold alerts for TTFT, TPS, and queue time using logging and monitoring services.

    4. Measuring Experience: No Metrics, No Optimization

    Instrument experience metrics into client-side telemetry to form an observability loop:

    1. - ttft_ms: time to first token
    2. - tps: decode speed
    3. - total_ms: end-to-end latency
    4. - tokens_in/out: input and output size
    5. - fallback_count: number of fallback events

    Bucket statistics by model tier and task type and compute P50/P95 percentiles. Only then can you tell whether “a few individual requests are slow” or “overall compute is under pressure.” Looking at averages alone tends to hide long-tail stalls.

    5. Conclusion

    Compute shortages are cyclical, but “completing the task with the most appropriate model, the shortest context, and the most reasonable reasoning mode” is a durable engineering capability. Make model tiering and routing, reasoning mode scheduling, context compression, and observable measurement solid, and even during supply contraction you can build a stable, predictable AI coding experience on top of general compute and container capabilities from platforms such as Baidu AI Cloud.