LLM Service Under High Concurrency: Capacity Planning, Token-Based Rate Limiting, and Degradation in Practice

    This article explains how to keep a large language model service stable during traffic spikes. It covers estimating instance counts from concurrency and token length with Little's Law, token-cost rate limiting with a token bucket, queue timeouts, tiered degradation, fault isolation, client retry budgets, and a pre-launch checklist.

    1. Tracing the Causal Chain

    To illustrate the problem, this article uses a hypothetical case. A model service normally peaks at 200 requests per second, and each request takes 6 seconds on average. After a new feature launches, evening peak traffic rises to 600 requests per second, three times the previous level. At the same time, two GPU nodes go offline one after another due to out-of-memory (OOM) errors, and the remaining nodes must absorb the full load.

    Memory usage and compute queues on the remaining nodes grow quickly. Time to first token (TTFT) rises from about 1 second to more than 20 seconds. Once queuing time exceeds the client timeout, clients receive 503 errors with the message “server busy.” The default configuration of many SDKs retries immediately up to 3 times, so each failed request becomes 4 requests. The original traffic plus the retry traffic overwhelms the system, and it stops responding within minutes.

    This chain of events breaks down into four links:

    Link Symptom Related section
    The capacity model only considers averages In-flight requests at peak far exceed what the cluster can handle 2
    Node failure shifts load to other nodes Remaining nodes are saturated and run out of memory 2, 4
    The queue has no limit Requests wait tens of seconds, and requests that have already timed out still occupy GPUs 4
    Client retries amplify traffic Failed requests turn into 4x traffic 4

    Breaking any one link reduces the impact of the incident. The sections below cover specific practices for each of the four links. All figures are hypothetical examples. Replace them with your own load test results.

    2. Estimating Instance Count from Concurrency and Token Length

    Many teams plan capacity based on average daily QPS, which underestimates peak load. The per-request cost of an LLM depends on the number of input and output tokens. At the same QPS, long-context requests can consume several times more GPU memory and compute time. Estimates must therefore account for both the request rate and the duration of each request.

    2.1 Calculating Concurrency with Little’s Law

    Little’s Law gives the number of requests in flight in a system:

    L = λ × W

    Here, L is concurrency, λ is the arrival rate (requests per second), and W is the average time per request (in seconds).

    Applied to the hypothetical case, off-peak concurrency is 200 × 6 = 1,200, and peak concurrency is 600 × 6 = 3,600.

    W has two components. The first is prefill time, which is proportional to the number of input tokens. The second is decoding time, which is proportional to the number of output tokens and usually accounts for most of the total. In the example, W is 6 seconds. If output length grows from 300 to 600 tokens, decoding time increases from 6 to about 12 seconds, and concurrency doubles with it. This is why estimates are sensitive to token length. Calculate W using P95 input and output lengths rather than averages.

    2.2 Calculating the Per-Instance Concurrency Limit

    The per-instance concurrency limit is mainly constrained by the KV cache capacity in GPU memory:

    KV cache per request = KV bytes per token × (input tokens + output tokens)

    Cmax = memory available for the KV cache ÷ KV cache per request

    KV bytes per token = 2 × number of layers × number of KV heads × head dimension × bytes per element (2 for FP16)

    Assume a model with 80 layers, 8 KV heads, a head dimension of 128, and FP16 precision. Each token then takes about 0.32 MB. With an average of 3,000 tokens per request (input plus output), each request takes about 0.96 GB. If an instance has 40 GB of memory available for the KV cache, then Cmax ≈ 41. All of these values are examples. Use your load test results.

    2.3 Instance Count Formula

    Safe concurrency = Cmax × target utilization

    Instance count N = ⌈ peak concurrency ÷ safe concurrency ⌉ + number of redundant instances

    The target utilization is typically 0.6 to 0.7, which leaves headroom for burst traffic.

    Using the same numbers, safe concurrency is 41 × 0.7 ≈ 28, and the base instance count is ⌈ 3,600 ÷ 28 ⌉ = 129.

    This is not enough. If the service must still handle peak load after losing 2 instances, 129 instances will fail. The remaining 127 instances can handle 127 × 28 = 3,556, which is below the peak of 3,600. With 131 instances, losing 2 still leaves 129, with a capacity of 129 × 28 = 3,612, which meets the requirement. The final configuration is therefore 131 instances.

    2.4 Common Mistake: Estimating from Average Daily QPS

    Average daily QPS reflects average load. Peak load is usually several times the average, so estimating from average QPS always leaves too few instances at peak. Another common mistake is applying one token length to all requests. After a long-context feature launches, average W may rise significantly. Recalculate using the actual input and output distribution instead of reusing old values.

    3. Token-Cost-Based Rate Limiting with a Token Bucket

    Limiting by request count does not reflect real cost. A 200-token Q&A and a 60,000-token document analysis both count as one request, but their resource consumption can differ by dozens of times. The rate limiting unit should therefore be token cost.

    3.1 Cost Calculation

    Request cost = input weight × input tokens + output weight × output tokens

    Decoding generates tokens one at a time, and each output token consumes more resources than each input token. The output weight is therefore typically 3 to 5. This article uses an input weight of 1 and an output weight of 4.

    When a request arrives, the gateway does not yet know the actual output length. It therefore reserves cost using max_tokens as the output upper bound, which prevents overselling. After the request completes, the gateway reconciles against the actual output length and refunds the excess.

    3.2 Bucket Parameters

    • Token refill rate R: Load testing shows that the cluster can sustain 250,000 cost units per second while keeping P95 queuing time under 5 seconds. Set R = 250,000.
    • Bucket capacity B: the allowed burst size. This is a 2-second burst, so B = 500,000.
    • Tenant share: each tenant can use at most 20% of the rate. The per-tenant bucket refills at 50,000 per second and has a capacity of 100,000.

    Requests that exceed a tenant’s quota receive a 429 response with a Retry-After header. The system returns 503 only when system-level protection is triggered.

    Take a request with 2,000 input tokens and max_tokens set to 800