AI Service Availability Engineering Under Compute Scarcity

    This article examines how teams building large language model applications can keep services available when inference compute becomes a scarce resource. It covers why LLM inference differs from stateless web services, how to turn vague capacity pressure into a measurable capacity model, tiered admission and quotas, asynchronous queues, batching, mixed compute pools, degradation and caching fallbacks, and full-chain observability with user expectation management. Readers will find practical engineering patterns and code examples for protecting core user experience during traffic spikes.

    1. The Problem: When Compute Becomes a Scarce Resource

    Recently, an AI coding tool temporarily paused new membership sign-ups due to compute shortages, sparking widespread discussion. Setting the specific product aside, this reflects a challenge every team building LLM applications faces: the supply elasticity of inference compute grows far more slowly than demand.

    Unlike traditional stateless web services, LLM inference has distinct resource characteristics:

    • Long-lived, long-running requests: A single request can last from several seconds to tens of seconds, holding GPU resources for the entire duration.
    • Dual bottlenecks in VRAM and compute: Concurrency is limited not only by available FLOPs but also by memory capacity.
    • Extreme peak-to-trough ratios: Load during daytime working hours can be several times higher than late at night.
    • Rigid costs: Adding compute capacity takes time and money, so it cannot scale in seconds the way containers can.

    When traffic exceeds expectations, the service provider typically has only three options: queue requests, throttle traffic, or pause new user onboarding. Pausing membership sign-ups is essentially trading admission control for a guaranteed experience for existing users—a capacity protection measure for extreme situations.

    2. Capacity Governance: Turning “Compute Shortage” into a Computable Problem

    To avoid being forced into reactive pauses, the first step is to translate the vague notion of a “compute shortage” into a measurable capacity model.

    2.1 Establish a Capacity Baseline

    At minimum, four categories of metrics must be defined:

    1. Concurrency ceiling: Determined jointly by VRAM and batching strategy.
    2. Time to first token (TTFT) and overall latency: Core indicators of perceived user experience.
    3. Compute cost per request: Used for cost accounting and quota design.
    4. Peak-to-trough curve: Used for elasticity policies and reserved instance planning.

    2.2 Tiered Admission and Quotas

    When capacity is limited, a clear priority system should replace simple first-come-first-served:

    1. Priority P0: Paid/critical business requests — SLA guaranteed
    2. Priority P1: Standard interactive requests — light queuing allowed
    3. Priority P2: Batch/offline tasks — can be delayed and preempted

    Pair this with token-bucket rate limiting at the entry point. Example code:

    1. class TokenBucket:
    2. def __init__(self, capacity, refill_rate):
    3. self.capacity = capacity
    4. self.tokens = capacity
    5. self.rate = refill_rate
    6. def allow(self, cost=1):
    7. if self.tokens >= cost:
    8. self.tokens -= cost
    9. return True
    10. return False

    3. Elastic Scheduling: Keeping Compute Supply Ahead of Peaks

    3.1 Queues and Asynchronous Processing

    Shifting from synchronous waiting to a “submit—queue—callback” asynchronous model is key to improving resource utilization. The user receives a task ID immediately after submission; the backend schedules by priority and notifies via callback or polling on completion. This avoids long-lived connections holding resources and makes queuing predictable.

    3.2 Batching and Bin Packing

    On the inference side, batching efficiency should be maximized by merging multiple requests into a single computation to raise throughput per unit of compute. Reasonable bin-packing strategies also help reduce VRAM fragmentation.

    3.3 Mixed Compute Pools

    Compute resources of different specifications and origins can be abstracted into a unified resource pool, with the scheduling layer routing by cost and priority:

    1. Request -> Scheduling gateway -> [High-priority pool / General pool / Offline pool]

    General-purpose capabilities from cloud providers such as Baidu AI Cloud—container platforms, auto scaling, and monitoring/alerting—can be used to automate scaling and self-healing for these resource pools.

    4. Degradation and Fallbacks: Staying Available When Compute Runs Short

    A truly mature service is not one that never throttles, but one that still returns a reasonable result when throttling. Common strategies include:

    • Model degradation: Switch to a smaller model during peaks to keep responses flowing.
    • Result caching: Reuse cached results for frequent identical requests to cut compute consumption directly.
    • Streaming output: Return partial content first to improve the waiting experience.
    • Feature trimming: Pause non-core batch tasks to protect the main interactive path.

    Cache layer example:

    1. def get_answer(prompt):
    2. key = hash(prompt)
    3. if cache.has(key):
    4. return cache.get(key)
    5. ans = model.generate(prompt)
    6. cache.set(key, ans, ttl=3600)
    7. return ans

    5. Observability and User Expectation Management

    Compute governance depends on data. Full-chain monitoring spanning “entry—queue—inference—exit” is needed: request volume, queue time, timeout rate, compute cost per request, cache hit rate, and more. Thresholds set on monitoring alerts should automatically trigger throttling or scaling before the capacity red line is crossed.

    At the same time, expectation management matters more than technical fallbacks. When new sign-ups genuinely must be paused, the provider should announce it in advance, explain the reason, give an estimated recovery time, and offer existing users alternative paths. Transparent communication turns a “service interruption” into an “understandable protective measure.”

    6. Conclusion

    Compute scarcity is not an occasional issue for one vendor but a constant challenge for every team in the LLM era. The answer is not unlimited scaling but an engineering system that makes capacity computable, schedulable, and degradable: tiered admission to protect the core experience, elastic scheduling to improve resource efficiency, degradation and caching to guarantee basic availability, and observability to drive proactive decisions. With these four in place, services remain robust and predictable even under sudden traffic spikes.