LLM Context Caching and Rate Limiting: Cost Control Strategies
This article explains why LLM services impose rate limits during peak demand by breaking down the real cost structure of inference, focusing on context caching (KV Cache reuse) and the compute amplification caused by waking cold sessions. It outlines how limits affect different user groups, then details platform-side governance such as tiered caching, context compression, request admission control, observability, and elastic scaling. It also gives users practical strategies and closes with the core tradeoff between free compute and unlimited expectations.
1. The Trigger: Why One Rate Limit Sparked a Wave of Complaints
During a period of tight compute capacity, an LLM service adjusted its policy for the free tier: inactive historical sessions were no longer guaranteed to resume directly, single input length was compressed to around 40,000 characters, and the conversation quota per unit of time was capped, while the paid API channel remained unaffected. Once the change was announced, app distribution channels and short-video communities quickly filled with one-star reviews. The most upset users even filed complaints through a municipal hotline, which eventually led officers to verify the situation in person.
From an engineering perspective, this was not a case of “the product got worse,” but a typical case of service tiering under resource constraints. To understand it, you first need to understand the real cost structure of LLM inference.
2. Root Cause: Context Caching and the Compute Amplification of “Cold Session Wake-Up”
An LLM has no long-term memory on its own. So-called “remembering the context” means recomputing attention over the entire token history of the conversation on every generation. To reduce this repeated overhead, the industry commonly adopts context caching (persistent reuse of the KV Cache): while a session is active, the intermediate states of the historical portion stay resident in memory or high-speed storage, and each new turn only requires incremental computation.
The cost curve therefore splits into two segments:
- Hot session: cache hit, extremely low marginal cost;
- Cold session: the cache is evicted under memory pressure (anywhere from hours to days), so when the user says just “hello,” the server must fully recompute hundreds of thousands of tokens.
So when a 200,000-token long session that has been idle for seven days is woken up, its instantaneous load is roughly equivalent to a dozen to forty normal turns of conversation in the same session. The user perceives “I only sent two words,” while the server perceives a small batch job. This is the direct trigger point for rate limiting.
Roughly speaking, the relative cost of a single request can be approximated as:
cost ≈ α * new_tokens + β * cached_hit ? 0 : history_tokens# α: prefill + decode cost of new tokens# β: extra factor from full recomputation (>1, includes queuing and GPU memory usage)
3. Layered Impact: Who Actually Gets “Blocked”
- Light users (a dozen or so Q&As per day): barely notice, as the cache is basically always resident.
- Knowledge-accumulation users: those who pile medical records, exam literature, or business templates into a single session over the long term face the highest cold wake-up cost.
- Long-text creators: those who keep hundreds of thousands of words of novels and character settings in one window hit quota or length limits after just a few days of inactivity.
- Long-term role-play users: emotion and settings depend heavily on continuous context, making them the most sensitive to continuity.
The conclusion is clear: the limits do not target users by “activity level” but by “context volume × cold-start probability.”
4. Platform-Side Governance
- Tiered caching and graded eviction. Put the hot tier in memory, the warm tier in high-speed storage, and the cold tier in object storage; change the eviction policy from pure LRU to a weighted score of “volume × time since last access.”
- Context compression and summarization. Apply rolling summaries to overly long histories, folding raw tokens into structured key points to significantly reduce recomputation scale.
- Request admission and queuing. Use a message queue to smooth peaks, and set concurrency and quotas by tenant tier to prevent cold wake-up jobs from crowding out online requests.
- Observability. Instrument telemetry to collect cache hit rate, cold wake-up ratio, and P95/P99 latency, and pair monitoring with alerts for capacity forecasting.
- Elastic scaling. Have the container platform auto-scale based on queue depth and GPU memory watermarks rather than CPU utilization.
- Productized communication. When a limit is triggered, provide a clear reason, actionable suggestions, and an export entry point, turning the “sense of failure” into “expectation management.”
5. User-Side Strategies
- Split sessions: divide by topic and keep each session on the order of a few thousand tokens;
- Build external memory: write long-term settings into local files or a vector store, and retrieve and inject them on demand each turn;
- Open with a summary: put a structured summary as the first message of a new session instead of the full history;
- Export promptly: periodically archive key conversations locally;
- Use the paid API for high-load scenarios to get a stable quota and longer cache guarantees.
6. Conclusion
The controversy over rate limiting is essentially a structural conflict between free compute and unlimited expectations. For platforms, the solution is a combination of cache tiering, context compression, and quota scheduling. For developers, migrating “memory” from the session window to searchable external storage is the engineering paradigm that stays stable over the long term. If you build this pipeline on Baidu AI Cloud’s general cloud capabilities (object storage, message queue, container platform, log service, and monitoring and alerting), you can push the cost per conversation into an operable range without sacrificing experience.
