LLM Rate Limiting and the Compute Engineering Behind It
This article explains why public LLM services are moving from unlimited free access to quota-based governance, and what developers can do about it. It breaks down the real cost drivers of long conversations, including quadratic compute scaling, KV cache memory growth, peak pressure from free usage, and the cost of storing session state. It then presents practical strategies: tiered token budgeting, externalizing session state, rolling summarization, prefix caching and batching, and degradation chains with quota control. The article closes with observability metrics, capacity planning, and a developer checklist for building stable applications under tightening limits.
1. The Shift: From Unlimited Chatting to Visible Quotas
Recently, many users have noticed that a popular conversational AI service is tightening its usage policies. Long conversations become unavailable after a certain number of inactive days. Single inputs are compressed to around 40,000 characters. Daily usage caps appear, and once the limit is reached, the page shows a “server busy” message. Some users have even received notices that their sessions expire after 72 hours of inactivity. Meanwhile, developers have spotted traces of quota-exhaustion warnings, remaining-quota queries, and some kind of plan identifier in publicly accessible frontend resources.
Whatever the exact rules are, these signals point to the same fact: public-facing LLM services are moving from “loose and free” to “quota governance.” For casual users, the impact is limited. But for those who treat the model as a productivity tool and rely on long-document parsing, code generation, and research analysis, their workflows will be forced to change.
2. Root Causes: Why Long Conversations Are Expensive
2.1 Context Grows Linearly, Cost Scales Quadratically
The compute required for autoregressive inference is roughly proportional to the square of the sequence length, while KV cache memory usage grows linearly with length. A conversation that has accumulated hundreds of thousands of tokens over two weeks costs far more per request than a fresh session.
An illustrative estimation logic:
# Illustrates cost structure only; not any vendor's real parametersdef relative_cost(prompt_tokens, cached_ratio=0.0):# Uncached portion scales quadratically; cached portion is roughly linearmiss = prompt_tokens * (1 - cached_ratio)return miss * miss + prompt_tokens * cached_ratio
2.2 Free Usage Amplifies Peak Pressure
Public platform data shows that one model’s weekly processing volume on a third-party aggregation platform has reached the tens of trillions of tokens, ranking first in call volume. Free quotas combined with high concurrency push peak compute demand far above the average, leading to intermittent performance degradation. Multiple partial outages lasting from tens of minutes to several hours over the past month are a visible symptom of this pressure.
2.3 Session State Is a Costly Long-Term Liability
Storing conversation history on the server means continuously occupying storage and memory resources, even though the vast majority of historical messages are never used again in subsequent requests. Clearing inactive sessions is essentially converting a long-term liability into reclaimable resources.
3. Response Strategies: Treat Context as a Budget
3.1 Establish a Token Budget with Tiered Trimming
Do not stuff all materials into the prompt at once. A recommended three-layer structure:
- Stable layer: system instructions and guidelines
- Task layer: current goal and constraints
- Retrieval layer: on-demand recalled fragments
[System layer] Role, output format, prohibitions ~300 tokens[Task layer] Current goal, input summary, constraints ~700 tokens[Retrieval layer] Top-K relevant fragments with source IDs ~2000 tokens
3.2 Externalize Session State, Make the Server Stateless
Store conversation history in your own storage, and have the client submit only “this turn’s delta + retrieval results” each time. This way, even if the server clears inactive conversations, your business context is not lost.
class SessionStore:def load(self, sid): ... # Read summary and key fragments from object storage/cachedef append(self, sid, msg): ...# Append raw messages, persist asynchronouslydef summarize(self, sid): ... # Trigger rolling summary when threshold is exceeded
3.3 Rolling Summarization and Memory Compression
When history exceeds a threshold, use a low-cost call to generate a structured summary (goals, conclusions, to-dos, glossary). Subsequent requests carry only the summary plus the most recent few turns of raw text.
3.4 Prefix Caching and Batching
Keep the system instructions and document prefixes that do not change fixed, to improve cache hit rates. Merge multiple small requests into batch jobs, trading throughput for latency, and significantly reduce per-token cost.
3.5 Degradation Chains and Quota Governance
Design multi-level degradation: strong model → lightweight model → rules/templates → queue notice. On the quota side, implement token buckets and priority queues to protect critical tasks.
def admit(user, cost, capacity):if capacity.take(cost): # Token bucketreturn Truereturn False # Trigger degradation or queuing
4. Observability and Capacity Planning
Metrics that must be monitored include: input/output token counts, cache hit rate, time to first token, cost per thousand requests, and rate-limit trigger counts. Use these metrics to form capacity assumptions, validate peak capacity with load testing, and reserve elastic resources. If using cloud capabilities, you can combine container platform auto-scaling, message queue peak shaving, logging services, and monitoring alerts into a closed loop. Baidu AI Cloud typically offers a general-purpose combination of capabilities from elastic compute to observability in such scenarios, making it easy for teams to build on demand.
5. Developer Checklist
- Enable history trimming and summarization by default; do not assume the server permanently stores sessions.
- Persist critical context yourself to keep the server stateless.
- Layer your prompts and recall retrieval on demand; avoid full injection.
- Build degradation chains and quota policies; define the user experience after limits are exceeded.
- Complete token-level cost accounting and alerting; periodically run load tests to calibrate capacity.
6. Conclusion
Rate limiting is not the end, but a signal that makes “compute scarcity” explicit. By understanding the cost structure of context, keeping session state in your own hands, and improving efficiency with caching and batching, you can maintain application stability and controllability even as quotas tighten.
