LLM Serving Rate Limiting and GPU Scheduling: A Practical Guide

    This guide explains how to protect large language model inference services under surging traffic by treating GPU memory and compute as fixed budgets. It covers session TTL and idle-context eviction, input length and daily quota limits, peak/off-peak pricing, concurrency isolation between consumer chat and API pools, availability metrics, observability, and long-term supply-side optimization, along with a deployment checklist for developers and platform teams.

    1. Why Traffic Spikes Can Take Down an Inference Service

    LLM inference is fundamentally different from a traditional stateless web service. Every request passes through two phases: Prefill (a one-time encoding of the input context) and Decode (token-by-token autoregressive generation). Decode repeatedly reads the key-value cache of prior tokens (commonly called KV Cache). As a result, a session that never ends can keep occupying expensive GPU memory for hours even when nobody is talking, simply because it still “exists.”

    This creates a familiar conflict: users want sessions to be kept forever and resumed at any time, while the platform must keep paying for every idle context. When call volume climbs quickly, idle sessions and extremely long contexts consume the GPU memory budget fast, causing new requests to queue, time-to-first-token (TTFT) to rise, and generation throughput to drop. Users experience this as “the service got slower” plus occasional failures.

    A recent round of governance measures taken by a platform facing a surge in traffic illustrates this conflict well: long sessions with no interaction for a certain number of days can no longer be resumed, the maximum input size per request was lowered, and a daily conversation cap was introduced. Abstracted out, these actions form a complete methodology for actively regulating compute load, and any team offering LLM capabilities externally can learn from it.

    2. Replace the “Unlimited Resources” Assumption With a Budget Model

    The first step in capacity planning is to accept that GPU memory and compute are a limited budget, not something that can expand indefinitely. In practice, the budget is usually split into three layers:

    • Memory budget: determines how many sessions can run concurrently and the upper bound on total context length;
    • Compute budget: determines total tokens generated per second (throughput) and the concurrency batch size;
    • Stability budget: headroom reserved for traffic bursts, failover, and canary releases, which should generally not be fully consumed.

    An actionable estimation approach (illustrative only, not measured data from any product):

    1. GPU memory per session ≈ resident model weights + per-token KV cost × context length
    2. Concurrent sessions ≈ (available memory - resident weights - safety margin) / memory per session
    3. Daily token capacity ≈ average throughput (tokens/s) × effective service seconds × target utilization

    Putting these three formulas into a capacity review template explains why limiting idle sessions and limiting single-request input length is more cost-effective than simply adding machines: the former reclaims memory held by invalid occupancy, while the latter reduces the multiplier term in memory usage.

    3. Session Lifecycle Governance: Give Context an Explicit Expiry

    Reclaiming idle sessions is essentially introducing a TTL (time to live) and an activity criterion. “Active” should not be judged by whether the user is logged in, but by whether meaningful interaction exists. Illustrative implementation:

    1. # Pseudocode: session activity and eviction decision
    2. SESSION_TTL_DAYS = 7 # retention limit without active interaction
    3. IDLE_EVICT_THRESHOLD = 1 # active interaction count threshold
    4. def should_evict(session, now):
    5. idle_days = (now - session.last_active_at).days
    6. return idle_days >= SESSION_TTL_DAYS and \
    7. session.active_turns < IDLE_EVICT_THRESHOLD
    8. def on_user_message(session, text, now):
    9. if should_evict(session, now):
    10. # Do not restore the old context; start a new session to avoid a huge Prefill spike
    11. return new_session(session.user_id, now)
    12. session.active_turns += 1
    13. session.last_active_at = now
    14. return continue_session(session, text)

    There are three key design points. First, eviction should degrade gracefully by prompting the user to start a new session, rather than letting the request fail outright. Second, avoid “resurrection Prefill”: resuming a very long session that has been backlogged for days produces one enormous encoding cost and easily triggers long-tail latency, so it is better to have the user explicitly rebuild context. Third, the eviction policy should be configurable and support canary rollout, with different TTLs per user tier (trial/paid/enterprise) instead of a one-size-fits-all rule.

    4. Context Length and Quotas: Joint Constraints on Two Multipliers

    The single-request input cap and the daily quota constrain the “per-request peak” and the “per-user daily cumulative total” respectively. They must be designed together, otherwise a loophole appears where each request is legal but the daily total breaks through.

    1. # Illustrative: tiered quota policy (values are structural examples only)
    2. limits:
    3. single_input_tokens: 40000 # max input tokens per request
    4. daily_tokens_per_user: 200000 # daily cumulative tokens per user
    5. max_concurrent_per_user: 2 # concurrency per user
    6. overflow_policy: reject_with_hint # return a readable hint on overflow, not a timeout

    Recommended engineering details: validate input length at the gateway layer up front so invalid requests never enter the inference queue; return an explicit error code and message on overflow to reduce repeated retries that cause a secondary impact; and use an approximate sliding window for quota counting, allowing a small margin of error in exchange for low overhead in the counting component.

    5. Peak/Off-Peak Pricing and Off-Peak Scheduling: Shave Peaks With Price Signals

    The most elegant way to shave a peak is not to reject, but to guide. Enabling time-based pricing on the API side, with off-peak prices roughly half of peak prices, lets batch jobs, offline summarization, and data-cleaning workloads migrate to low-traffic hours automatically. Combined with queue priority, the effect is more pronounced:

    1. Peak hours: prioritize online interaction (low TTFT); downgrade or queue batch jobs
    2. Off-peak hours: open up batch concurrency to raise overall utilization

    Note that price signals only work when SLA tiers are clear: online interaction promises low latency, while offline jobs promise a completion time. If both share the same queue, any “off-peak” effort degrades into “everything gets slower together.”

    6. Concurrency Isolation: Separate Consumer and API Resource Pools

    Consumer chat and developer API traffic have completely different characteristics: the former is short, bursty, and experience-sensitive; the latter involves long contexts and is retryable and queueable. Putting both in the same resource pool inevitably hurts each other. The common industry practice is physical or logical isolation, with an independent concurrency cap per model class (the original text mentions a platform setting account-level concurrency caps per model, which follows this idea).

    1. Pool A (consumer interaction): high priority, short timeout, fast failure
    2. Pool B (API calls): independent concurrency quota, supports queuing and retries, can shift off-peak

    After isolation, the failure domain also converges: a traffic spike on the consumer side will not exhaust the API concurrency quota, and vice versa.

    7. Availability Metrics: Don’t Hide Experience Problems Behind One “99.9%”

    The availability figures in the original text (roughly 99.46% for one class of interface and 99.74% for another from August to October) point to a commonly overlooked issue: percentages are not intuitive. In a year of 8,760 hours, 99.46% is about 47 hours of unavailability, and 99.74% is about 22.8 hours. To users, “about two fewer days per year” is far more tangible than “four nines.”

    A more rigorous measurement should include at least four dimensions:

    • Availability: share of successful requests, distinguishing “fully unavailable” from “performance degradation”;
    • Latency percentiles: P50/P95/P99 for TTFT and end-to-end duration;
    • Error composition: respective shares of rate limiting, timeouts, upstream failures, and content policy blocks;
    • Impact scope: share of affected users, duration, and whether adjacent capabilities (such as search augmentation or file parsing) are affected.

    Incident reviews should also distinguish severity levels: performance degradation (slower, occasional failures, still submittable) and partial outage (a certain capability unavailable) should follow different response and compensation processes rather than all being handled as a “full outage.”

    8. Observability and Playbooks: Compress Incidents From Hours to Minutes

    Making the strategies above effective requires a minimal observability loop: the gateway records per-request input length, queue time, TTFT, generation length, and finish reason; the inference side exposes GPU memory usage, batch size, and KV cache hit rate; the business side counts quota hits and reclaimed sessions. Set tiered alerts on these metrics and prepare playbooks: automatic scale-out, automatic degradation (turning off non-core adjacent capabilities), and automatic off-peak shifting (pausing low-priority batch jobs).

    1. Metric → threshold → action
    2. TTFT P95 above threshold → pause the batch queue → observe for 5 minutes
    3. GPU memory usage > 85% → accelerate idle session reclamation → cap very long inputs
    4. Error rate spikes → open the degradation switch → keep basic chat available

    9. The Long-Term Fix on the Supply Side

    Scheduling and rate limiting are about reducing demand; scaling out is about increasing supply. Common long-term approaches in the industry include building large-scale compute clusters, adding more domestic accelerator chips, and lowering per-request compute cost through model distillation and quantization. For most teams, a more realistic path is to work on all three layers at once: in the short term, use quotas and reclamation to stabilize experience; in the medium term, use time-based pricing and concurrency isolation to raise utilization; in the long term, optimize models and inference engines (such as more efficient cache management and continuous batching) to push down per-token cost.

    10. A Deployment Checklist for Developers and Platform Teams

    • Document session TTL, single-request input caps, and daily quotas in the product docs, with readable hints on overflow;
    • Validate length and quota at the gateway up front so invalid requests never enter the inference queue;
    • Isolate consumer and API resource pools, each with its own concurrency cap and timeout policy;
    • Enable off-peak shifting and time-based price signals for offline jobs, with clear SLA tiers;
    • Build multi-dimensional availability metrics and tiered incident playbooks, review them regularly, and publish them;
    • Use the capacity formulas in reviews, and treat “idle sessions” and “overly long contexts” as the primary optimization targets.

    Overall, usage limits are not “a worse service” but an inevitable engineering choice under a compute budget constraint. Combining idle context reclamation, input length limits, daily quotas, peak/off-peak scheduling, concurrency isolation, and observability into one system is what lets you protect the experience of active users while keeping long-tail workloads from dragging down overall stability as traffic keeps climbing.