Scaling LLM APIs to a Million Daily Active Users: Technical Challenges and Engineering Practices

    When an AI coding tool grew its API daily active users from roughly 200,000 to over 1.5 million in about a month, with daily token consumption reaching around 92 trillion, it triggered a real-world high-concurrency stress test. This article breaks down what that growth means technically, then walks through a layered approach to handling it: admission control with identity-based quotas, priority queues and traffic shaping; inference-side elasticity, batching, caching and predictable degradation; token cost attribution; full-chain observability tied to SLOs; and a four-stage rollout path. The core takeaway is to build guardrails and observability first, then pursue elasticity and cost reduction.

    1. What a Million Daily Active Users Actually Means

    A team behind an AI coding tool recently disclosed its operating data for the first time: over roughly one month, daily active users on its official API climbed from just over 200,000 to more than 1.5 million, with single-day token consumption reaching around 92 trillion. Put together, these two numbers yield a key metric — average daily token consumption per user of roughly 6 million.

    At this scale, callers are no longer light users who “ask an occasional question.” They have embedded model capabilities into daily development workflows: code completion, cross-file understanding, unit test generation, and review comment organization are all triggered at high frequency. For the platform side, user growth is linearly visible, but resource pressure is often superlinear, for three reasons:

    • Context expansion: Inputs in coding scenarios are far longer than in ordinary Q&A. A single request may carry an entire file plus dependency snippets, and attention computation and GPU memory usage rise quickly with sequence length.
    • Sharp peaks and valleys: Calls concentrate during working hours and nearly drop to zero at night. A smooth daily average masks minute-level spikes.
    • Long-session accumulation: Multi-turn conversations keep appending history, with cache hits and invalidations alternating, making scheduling significantly harder than for stateless short requests.

    So the real technical question behind a million daily active users is not “can we handle the average load,” but “can we keep tail latency under control during spikes and avoid wasting resources during valleys.”

    2. Layered Governance at the Access Layer: Stop Instability Before Inference

    Facing a tenfold jump in traffic, the first step is not scaling up but establishing layered admission.

    The first layer is identity and quota. Use an API key or token as the unique caller identifier, and set a three-dimensional quota for each subject: requests per minute, concurrency, and daily token cap. Quotas must be “soft first, hard as backstop”: soft limits drive observation and alerting, while hard limits protect the backend.

    The second layer is the priority queue. Split requests into three tiers — online interactive (a user waiting for completion in the editor), near-line tasks (batch test generation, batch refactoring), and offline tasks (repository-level scanning, documentation generation) — and bind each to an independent concurrency pool so offline batch jobs cannot starve the interactive path.

    The third layer is admission shaping. Smooth burst traffic with a token bucket, and run a length pre-check on extremely long-context requests with a degradation suggestion, rather than letting them sit in the queue for a long time.

    1. # Example: three-dimensional quota + priority-based pooling admission check
    2. async def admit(req, quota):
    3. if not quota.allow_request(req.owner): # requests per minute
    4. raise RateLimited("RPM_EXCEEDED")
    5. if not quota.reserve_tokens(req.owner, req.est_tokens): # estimated token quota
    6. raise RateLimited("TPM_EXCEEDED")
    7. if req.est_tokens > MAX_CONTEXT:
    8. return degrade(req) # truncate / summarize / reject with a message
    9. pool = POOLS[req.priority] # interactive / nearline / offline
    10. return await pool.submit(req)

    One point deserves emphasis: estimated token counting is often overlooked. Discovering an overage only after a request enters the inference stage means resources have already been spent and rollback is extremely costly. Doing an approximate count with the tokenizer at the admission stage is the most cost-effective protection available.

    3. Inference-Side Elasticity and Efficiency: Match Compute to the Curve

    After admission, the core tension becomes “how to sustain throughput at peaks and compress cost at valleys.”

    Scale based on queues, not CPU. Inference service bottlenecks usually show up as waiting queue length and time-to-first-token. Driving scaling with these two signals tracks real user experience more closely than traditional resource utilization. Scaling actions must allow for a cold-start window, since loading model weights and warming GPU memory take time. The policy should therefore “scale up a bit early and reclaim slowly” to avoid thrashing.

    Differentiate batching by scenario. Static batching is simple but has poor tail latency; continuous batching (dynamically inserting and retiring requests along the sequence dimension) markedly improves GPU utilization and is the common approach for interactive scenarios. Offline tasks are the opposite: accumulate large batches and run at full throughput.

    Cache in layers. Repeated requests sharing the same prefix can reuse computed results through prefix caching, which pays off especially in coding scenarios — when the same file is submitted for review repeatedly, the system prompt and file header are often identical. Session-level and result-level caches should have separate invalidation policies to avoid stale context contaminating output.

    Make degradation predictable. During peaks, enable in order: shorter maximum output length, disabling non-essential deep reasoning, routing some requests to smaller-parameter models, and deferring offline tasks. Degradation rules must live in configuration and support canary rollout, not ad hoc code changes by hand.

    4. Token Cost: From a Bill to an Attributable Ledger

    At 92 trillion tokens per day, the granularity of cost governance determines how much optimization room exists. A workable approach is a metering ledger with dimensions for calling subject, business scenario, model tier, and input/output split:

    Dimension Purpose
    Calling subject Quota adjustment, locating abnormal usage
    Business scenario Determining which features actually deliver value
    Input/output split The output side is usually the main cost driver, so optimize it first
    Cache hit rate Measuring prefix reuse and scheduling quality

    Rank optimization measures by return on investment. Typically: compress system prompts and redundant context, apply retrieval-style trimming to long files before sending them to the model, fix stable prefixes at the front to hit the cache, route small tasks to small models, and move recomputable offline tasks to low-price windows. None of these change the external interface semantics, so they are low-risk changes.

    5. Observability and Stability: Turn Perception into Metrics

    At a million daily active users, user-perceived “slowness” often appears before monitoring alerts do, so the metric system must cover the full chain:

    • Gateway layer: request volume, rate-limit trigger count, error rate by subject;
    • Queue layer: wait time distribution (P50/P90/P99), queue depth, timeout drops;
    • Inference layer: time-to-first-token, inter-token generation interval, batch size, GPU memory usage, cache hit rate;
    • Business layer: task success rate, user retry rate, degradation trigger ratio.

    Alerts should bind to SLOs rather than single-point thresholds, for example “P99 time-to-first-token for interactive requests stays under the configured value within five minutes,” paired with a capacity watermark dashboard that turns “how much headroom remains before the scaling threshold” into an actionable early signal. Load testing must be routine, replaying realistic length distributions and peak-valley curves rather than applying uniform traffic.

    6. Rollout Path: Four Stages

    1. Observability first: Complete per-subject metering and full-chain metrics, and identify whether the current bottleneck is the gateway, the queue, or GPU memory.
    2. Guardrails in place: Ship three-dimensional quotas, priority pooling, length pre-checks, and configurable degradation.
    3. Efficiency gains: Introduce continuous batching, prefix caching, small-model routing, and context trimming.
    4. Cost loop closed: Build an attributable ledger, review unit task cost by scenario, and keep iterating.

    If the overall architecture runs on general capabilities such as Baidu AI Cloud’s container platform, object storage, message queue and logging services, and monitoring and alerting, the layers above map directly onto elastic scaling policies, asynchronous task buffering, and a unified observability dashboard, reducing the burden of building infrastructure in-house.

    7. Conclusion

    Gaining more than a million daily active users in a month is essentially a real high-concurrency stress test. What it validates is not a single model’s point capability but the engineering maturity with which a platform delivers “intelligence” reliably on every request. For developers, the conclusion worth keeping is one sentence: build guardrails and observability first, then talk about elasticity and cost reduction — only then does scale growth turn from a risk into compounding returns.