Designing Quotas for Long Sessions: Engineering Trade-offs Between Session Freezing, Input Limits, and Daily Usage Caps
This article explains why LLM services need quotas and compares three common mechanisms: idle session freezing, per-request input length limits, and daily usage caps. It covers the technical trade-offs of each, shows a sample quota-check flow and background freeze job, and describes how long-session use cases such as roleplay and companion apps affect quota design. It also outlines practices for rolling out and rolling back quota changes.
1. Background: Why Quotas Are Required on the Server Side
Some general-purpose LLM services have recently changed usage limits for free users, and many users reported a worse experience. To understand these changes, it helps to first understand how server-side resources are consumed.
LLM inference has two main costs. The first is compute. Each output token requires a full forward pass through the model. The second is GPU memory. During generation, the model keeps cached key and value vectors for previous tokens, known as the KV cache. The size of the KV cache scales roughly linearly with context length. A single window that has accumulated tens of thousands of characters of settings and hundreds of conversation turns uses far more memory than a one-off question.
Servers also handle many concurrent requests, and total resources are limited. Platforms therefore usually need three types of controls:
- Limit the stateful resources a single session can occupy.
- Limit the compute size of a single request.
- Limit the total consumption of a single user over a period of time.
These three types of controls map to the three rules discussed below. Their purpose is to keep the system stable, and none is inherently right or wrong. The real questions are whether the rules are predictable, whether they include a transition period, and whether the messages shown to users are clear.
2. The Technical Basis of Three Common Limit Mechanisms
2.1 Idle Session Freezing
Idle session freezing means that when a session receives no new requests for a set period, the system moves it out of the active state and keeps only its persisted history.
The core idea of this design is to replace “active state that occupies memory” with “stored state that can be rebuilt at any time.” A frozen session no longer occupies the inference context cache, but its message history must remain in storage.
The key parameter of a freezing rule is the idle threshold. The following values are examples and do not represent any specific service:
- A 7-day threshold has almost no effect on light users.
- A 72-hour threshold noticeably affects heavy users who run long sessions.
A shorter threshold reclaims more resources, but it raises the risk of wrongly freezing high-value long sessions. Before setting the threshold, teams should analyze historical data and examine the distribution of return intervals for long sessions.
A common engineering problem is that a frozen session can be read but not continued. Users find this state hard to understand. If the system only returns “insufficient resources,” users cannot tell whether the session is permanently gone or can be restored. A better approach is to distinguish three states: readable and resumable, requires restoration, and archived. Each state should have its own action entry point.
2.2 Single-Input Length Limit
A single-input length limit caps how much content one request can carry. Its purpose is to control the peak compute and memory usage of a single inference call.
Pay attention to the unit of measurement here. The system measures tokens internally, but users see characters. Because tokenization varies, there is no fixed conversion between character count and token count. The same number of characters can map to very different token counts depending on the language and the content. Documentation that describes a limit should therefore state the measurement basis.
There are three strategies for handling overly long input:
- Direct rejection: Simple to implement, but the worst user experience.
- Head truncation: Keeps the most recent content and drops earlier settings, which can cause the character to “forget” key details.
- Summary compression: Compresses earlier content into a summary before keeping it. This costs more but loses the least information.
For scenarios with long setting documents, the recommended approach is to split settings into structured fields, such as character name, personality, relationships, taboos, and worldbuilding. Each request then injects only the fields it needs, rather than sending the full document every time.
2.3 Daily Usage Cap
A daily usage cap is the total amount a user can consume within one calendar day. Its implementation depends on the measurement period and the reset time.
Common rate-limiting algorithms include fixed window counting, sliding window counting, and the token bucket. They differ as follows:
| Algorithm | Implementation Complexity | Boundary Spikes | Typical Use Case |
|---|---|---|---|
| Fixed window counting | Low | Yes. Usage can briefly double when the window switches | Coarse daily quotas by calendar day |
| Sliding window counting | Medium | Fewer | Scenarios that need smooth limiting |
| Token bucket | Medium | Controlled | Allows short bursts while limiting the long-term average |
The reset time is the most controversial part of a daily cap. If a rule only says “reset at midnight,” users in different time zones will interpret that time differently. Teams should state the time zone that applies to each user and show the specific recovery time in the message.
3. Example Implementation of a Quota Check
The pseudocode below shows the main flow of a request passing through quota checks. It orders the three rules by check sequence and returns actionable rejection reasons.
function check_quota(user, request):session = load_session(request.session_id)if session.status == "frozen":return reject(reason = "Session is frozen",readable = true,hint = "History can be viewed. Resume the session to continue sending messages")if request.input_tokens > max_input_tokens:return reject(reason = "Input exceeds the length limit",limit = max_input_tokens,hint = "Shorten this input, or summarize the settings before sending")period_key = compute_daily_period_key(user.timezone)used = read_usage(user.id, period_key)estimated = request.estimated_tokensif used + estimated > user.daily_quota:return reject(reason = "Daily quota exhausted",reset_time = next_period_start(user.timezone),hint = "The quota resets at the time shown, and you can continue using the service then")atomic_increment_usage(user.id, period_key, estimated)return pass
When implementing this flow, keep the following points in mind:
- Atomicity: Reading and writing usage must happen in a single atomic operation. Otherwise, concurrent requests can all pass the check at the same time and exceed the quota.
- Separate estimation from settlement: Before a request starts, reserve quota based on the estimated value. After it ends, correct the reservation with the actual value. If estimates deviate significantly, recalibrate the estimation model regularly.
- Rollback on failure: If inference fails, release the reserved quota so users do not pay for server-side errors.
A background job can scan the session table on a schedule, update statuses in batches, and make sure history data is never deleted:
scheduled job, runs every hour:for each session where status == "active" and last_active_time < now - idle_threshold:set session status to "frozen"release the session's inference context cachekeep all history messages and settings data
The key point here is to handle “releasing the context cache” and “keeping history data” as separate operations. The first releases compute resources. The second protects user data. Confusing the two can cause irreversible data loss.
4. Special Considerations for Roleplay and Companion Scenarios
These scenarios differ clearly from general question answering, so quota design should address them separately.
First, users run many sessions in parallel. A user may keep a dozen or even dozens of independent sessions, each tied to its own storyline or relationship setup. If quotas count sessions, users hit limits quickly. If quotas count active time, it becomes hard to tell meaningful use from sessions that are simply left open.
Second, context accumulates heavily. Character cards, worldbuilding documents, and plot history keep building up. A single session’s context can reach tens of thousands of characters and hundreds or even thousands of turns. The same rule therefore affects long-session users much more than typical users.
Third, user expectations are more sensitive. For companion products, session continuity is part of the product value. If a rule takes effect suddenly without a transition period, users experience it as the product being taken away, not as resources being reclaimed reasonably.
To address these issues, consider the following design choices:
- Structured settings: Split character settings into fields, store them separately, and inject them only as needed to reduce repeated consumption.
- Summarized history: Periodically compress early plot into a summary that keeps key events and relationship changes. This lowers the cost of rebuilding a session.
- Advance notice before freezing: Show an in-app notice before a session is due to freeze, with options to save a summary or resume manually.
- Tiered policies: Use different thresholds for paid users, long-term active users, and new users to avoid a one-size-fits-all approach.
5. Managing Rule Changes
Quota rules are part of the product contract. Changes to them should follow a management process similar to changes to an API.
Advance notice and transition period: Announce major rule changes ahead of their effective date. For rules with broad impact, first roll out to a subset of users as a staged release. Watch complaints, churn, and retention data before enabling the rule for everyone.
Metrics monitoring: Monitor at least the following metrics:
- Daily number of frozen sessions and the recovery rate after freezing
- Share of requests that fail because of quota rejections
- Frequency of key terms in user feedback
- Distribution of rejection rates across time periods, used to judge whether the reset time is reasonable
Error message design: Each message should include three elements: what happened, why it happened, and what the user can do. For example, “Your daily quota is used up and will reset at [time]” works better than “Server busy.” Vague explanations can make users think the service is broken, which increases frustration.
Rollback plan: Before a rule goes live, prepare a rollback plan. It should include a configuration switch, a snapshot of the previous rule parameters, and a decision on how to handle sessions that were frozen under the new rule after a rollback.
6. Trade-offs in Choosing a Design
When designing quotas, teams must balance the following dimensions:
| Dimension | Favors Strict Limits | Favors Relaxed Experience |
|---|---|---|
| Resource protection | Strong | Weak |
| User continuity | Weak | Strong |
| Operating cost | Low | High |
| Rule understandability | Depends on message design | Usually better |
| Rollback difficulty | Low (configuration switch) | Low (configuration switch) |
No single design is optimal everywhere. A sound approach is to first define the core user group, then set thresholds based on that group. If core users are heavy users who run long sessions, prioritize keeping history resumable and messages clear. Address resource pressure through tiering and summarization.
7. Implementation Checklist
Before launching any quota rule, complete the following checks:
- Analyze historical data to confirm the return-interval distribution for long sessions.
- Define the measurement unit clearly. Use tokens as the internal basis, and explain the conversion method in external documentation.
- Confirm the time zone used for the reset time, and show the specific time in messages.
- Verify atomicity under concurrent requests to prevent overuse.
- Confirm that freezing operations never delete user history data.
- Prepare a staged rollout plan, a monitoring dashboard, and a rollback switch.
- Review all message text to make sure every rejection includes a reason and a clear next step.
A quota is a resource management tool. What users experience is the transparency and predictability of the rules. Getting both right lets a service control costs while keeping its credibility.
