Scaling AI Applications to Millions of Daily Users: The Engineering Logic Behind Token Economics
This article examines the engineering shift that occurs when an AI application moves from a working demo to serving real production traffic at scale, using the example of an office productivity agent that surpassed ten million daily active users and over ten billion tokens consumed per day. It explains how to treat tokens as a first-class capacity unit, build a capacity and cost attribution model, and design a layered inference pipeline of intent routing, small models, and large models supported by semantic caching. It also covers dual-dimensional governance of cost and performance, quota and graceful degradation mechanisms, multi-device session consistency, release strategies such as canary and shadow traffic, and a practical launch checklist for teams moving from "usable" to "scalable and reliable."
1. What a Set of Operating Metrics Reveals About the Scaling Inflection Point
A major internet platform disclosed in its latest quarterly report that an intelligent office application has surpassed ten million daily active users, with average daily token consumption exceeding ten billion. Third-party monitoring data also shows that leading products in the office AI agent category have a combined monthly active user base of more than thirty million across multiple platforms. In the same quarter, the platform’s capital expenditure and R&D investment rose significantly year over year, and operating profit came under short-term pressure from the new AI product investment, while core business profit, excluding the new AI product, continued to grow.
The value of these figures lies not in the exact numbers but in the engineering fact they reveal: AI applications have moved from “usable in a demo” to “carrying real production traffic.” When tokens become a capacity unit much like QPS, the central design challenge shifts from tuning model quality to balancing unit token cost against service quality. This article uses that tension as its main thread to discuss reusable architectural methods.
It should be noted that business models vary widely across companies. The metrics above serve only as an order-of-magnitude reference and should not be applied directly to your own capacity planning.
2. Treating Tokens as First-Class Citizens: Capacity Modeling and Cost Attribution
Traditional web applications measure capacity in requests and bandwidth. AI applications must add tokens to that equation. A workable capacity model includes at least four variables:
Daily tokens ≈ DAU × sessions per user × turns per session × average tokens per turnCost ≈ input tokens × input price + output tokens × output price + retrieval and tool-call overhead
The average tokens per turn consist of three parts: system prompts and tool definitions (fixed overhead), context injected by retrieval (variable overhead), and conversation history (accumulating overhead). Many teams lose control of costs after launch because they fail to track fixed overhead separately. A system prompt containing a dozen or more tool definitions can consume thousands of tokens on every single call.
The engineering response is layered attribution: tag every call at the gateway, recording the scene, tenant, model tier, and cache hit status, producing a bill that can be drilled down by dimension. A sample structure looks like this:
{"trace_id": "b7f2...","scene": "doc_summary","tenant": "t_1024","model_tier": "small","tokens": { "prompt": 3120, "completion": 480, "cached_prompt": 2800 },"latency_ms": { "first_token": 420, "total": 3650 }}
With this instrumentation in place, capacity planning has a real basis, and cost optimization does not devolve into blindly compressing context.
3. Layered Design of the Inference Pipeline
An inference pipeline supporting millions of daily active users is generally not suited to a single end-to-end model. Instead, it adopts a three-tier structure of “routing, small model, large model.”
The first tier is intent routing. A lightweight classification model or rules engine determines whether a request is casual chat, retrieval-based question answering, structured extraction, or complex reasoning, keeping most simple traffic away from expensive models. Routing accuracy matters more than routing speed, so a fallback path of “escalate when confidence is insufficient” must be preserved.
The second tier is the capability layer. Retrieval-augmented generation brings in enterprise private knowledge, while tool calling handles interaction with business systems. The key constraint at this layer is the context budget: trade-offs must be made among the number of retrieved items, snippet length, and latency. The common practice is to keep only a small number of highly relevant snippets after reranking and to summarize and compress conversation history.
The third tier is the complex reasoning layer. High-capability models are invoked only for scenarios such as multi-step planning, code generation, and long-document analysis, with result caching and batching used to smooth out peaks.
Working alongside this structure is semantic caching. Reusing historical answers for high-frequency similar questions is the most direct way to reduce token consumption, but similarity thresholds and expiration policies must be set to avoid returning stale information to users:
def get_answer(query, tenant, threshold=0.94):hit = semantic_cache.lookup(query, tenant)if hit and hit.score >= threshold and not hit.expired():return hit.answer, {"cached": True}answer = pipeline.run(query, tenant)semantic_cache.store(query, tenant, answer, ttl=3600)return answer, {"cached": False}
4. Dual-Dimension Governance of Cost and Performance
Cost governance cannot rely on “switching to a smaller model” alone. It requires a measurable set of metrics: daily cost per active user, cache hit rate, P95 first-token latency, retry rate, and human takeover rate. These metrics need to feed into the monitoring and alerting system simultaneously, with threshold-based linkage configured.
A more robust approach is to introduce quotas and graceful degradation. When backend inference services run at high utilization, features should be disabled in order of tenant priority: first long context, then multi-turn rewriting, then lowering the maximum generation length, ensuring the core path stays available. Degradation must be ordered and observable; otherwise, an incident escalates into a full outage.
On the infrastructure side, the common practice is to use a container platform for elastic scaling, a message queue for request buffering and asynchronous processing, object storage for model files and knowledge base snapshots, and logging and monitoring services for full-chain tracing. These are standard industry categories. When selecting them, focus on elastic response speed and completeness of observability rather than single-point performance metrics.
5. Multi-Device Consistency and Stability
Traffic for office applications comes from desktop, mobile, and web clients, and the same session may continue across devices. This requires session state to be externalized to a distributed cache or database, messages to be pushed over long-lived connections, and idempotency to be guaranteed: resubmitting the same request must not produce duplicate writes.
For release strategy, AI applications are advised to adopt canary plus shadow traffic: a new version first takes a small share of real traffic, while shadow traffic replays production requests for comparison. Traffic is gradually increased only if metrics do not degrade. Model or prompt changes should likewise be treated as a release, with rollback capability in place.
6. Launch Checklist
- Have you established token attribution billing by scene and tenant?
- Have you measured and optimized the fixed overhead of system prompts and tool definitions?
- Do you have intent routing and model tiering to avoid sending all traffic to high-capability models?
- Does your semantic cache have a similarity threshold, TTL, and expiration mechanism?
- Have you defined a degradation order and quota policy, and connected them to monitoring and alerting?
- Is session state externalized, and is cross-device continuation idempotent?
- Can model and prompt changes be canaried and rolled back?
Competition in AI applications ultimately comes down to two engineering curves: unit token cost and stability. Bringing tokens into the capacity and cost model, and using a layered architecture and observability system to safeguard quality, is the critical path from “usable” to “scalable and reliable.”
