Behind LLM Usage Quotas: Resource Costs of Long Conversations and Tiered Service Design

    As large language model (LLM) services scale, providers are increasingly implementing usage quotas, input length limits, and idle session reclamation. This article explores the engineering rationale behind these restrictions, focusing on the resource costs associated with long conversations, particularly KV Cache memory consumption. It details common quota dimensions, design principles for converting resource usage into measurable metrics, and reliability strategies such as token bucket rate limiting and circuit breakers. Finally, it covers best practices for maintaining user trust and ensuring transparent, predictable service rules.

    1. Background: From Unlimited Free Access to Tiered Services

    Recently, multiple LLM service providers have adjusted their usage rules, including limiting single input lengths, reclaiming long-inactive sessions, and setting daily usage caps. These adjustments are not isolated incidents but common choices as inference services scale.

    Free services can run long-term based on two premises: the compute cost per request is controllable, and traffic peaks can be smoothly absorbed by the resource pool. As user numbers grow, individual sessions become longer, and high-frequency calls concentrate, these premises break down. Providers must translate resource consumption into measurable, allocatable metrics and design rules accordingly.

    Understanding this helps view quota strategies from an engineering perspective: it is fundamentally a resource scheduling problem, not purely a business decision.

    2. Where Do the Resource Costs of Long Conversations Come From?

    2.1 KV Cache and Memory Usage

    When generating text, Transformer-based LLMs save the Key and Value vectors from the attention mechanism for each processed token. This intermediate data is called the KV Cache. The cache prevents recalculating the entire history for every new token generated, thereby reducing computation.

    The tradeoff is memory. The KV Cache typically resides in the GPU’s High Bandwidth Memory (HBM). Its size can be estimated using the following formula:

    1. KV Cache Bytes ≈ 2 × Number of Layers × Number of KV Heads × Head Dimension × Sequence Length × Bytes per Element

    Here is a calculation example using hypothetical configurations (values are illustrative, not actual test data from a specific model): 32 layers, 8 KV heads, 128 head dimension, 32768 sequence length, half-precision (2 bytes per element). Substituting into the formula, the KV cache for a single sequence is approximately 4 GiB. If a single card serves multiple long conversations simultaneously, memory is rapidly exhausted.

    2.2 Relationship Between Session Length and Cache Growth

    The size of the KV Cache scales linearly with context length. A session accumulating hundreds of thousands of words of dialogue will see its cache grow continuously. Even if the user sends no new requests, as long as the server retains this state, memory remains occupied.

    This explains why long-idle sessions need to be reclaimed: the benefit of keeping them is low, but the occupied resources persist.

    2.3 Compound Impact of Computation and Concurrency

    Long contexts also increase the computational overhead of the attention mechanism, raising the latency of single-generation steps. When high concurrency and long contexts occur simultaneously, the system may experience slow responses, increased generation latency, and occasional request failures. Such performance degradation often precedes complete unavailability, requiring operations teams to identify and handle it hierarchically in advance.

    3. Common Quota Dimensions and Their Rationale

    Providers typically set constraints across several dimensions, each corresponding to different resource issues.

    Quota Dimension Primary Resource Constrained Rationale
    Single input length limit Memory, single compute duration Prevents a single request from monopolizing compute resources
    Idle session reclamation Long-term occupied memory and storage Reclaims inactive states
    Daily or per-minute token quota Total compute power Smooths traffic, ensures overall availability
    Concurrency and priority Scheduling queue Ensures responsiveness for paid or critical tasks

    These dimensions can be combined. For instance, a free tier might have lower quotas and shorter session retention, while a paid tier offers higher limits and priority scheduling. The key is that rules must correspond to actual resource costs and be transparent to users.

    4. Design Principles: Converting Resources into Measurable Metrics

    4.1 Token as the Unit of Measurement

    The number of input and output tokens is the primary source of inference cost, so metering should be token-based rather than per-request. Billing per request gives long-text requests and short Q&A sessions the same treatment, which contradicts actual costs.

    4.2 Externalizing and Compressing Session State

    The core issue with long sessions is the infinite growth of historical content. Three common approaches exist:

    1. Sliding Window: Retains only the most recent rounds of dialogue, discarding older content. Simple to implement but loses early information.
    2. Summary Compression: Distills older history into a summary, used alongside recent dialogue as context. Retains key information, but the summary itself might miss details.
    3. External Storage and On-Demand Retrieval: Stores full history in object storage or databases, retrieving only relevant fragments into the context based on the current query. Suitable for scenarios requiring extensive historical tracing.

    These methods can be combined. The following code demonstrates the basic idea of summary compression.

    1. from typing import Callable
    2. KEEP_RECENT = 6 # Number of recent messages to always retain (example value)
    3. def compact_history(
    4. messages: list[dict],
    5. max_tokens: int,
    6. count_tokens: Callable[[str], int],
    7. summarize: Callable[[list[dict]], str],
    8. ) -> list[dict]:
    9. """When history exceeds the budget, compress older messages into a summary."""
    10. total = sum(count_tokens(m["content"]) for m in messages)
    11. if total <= max_tokens or len(messages) <= KEEP_RECENT:
    12. return messages
    13. head, tail = messages[:-KEEP_RECENT], messages[-KEEP_RECENT:]
    14. summary = summarize(head)
    15. return [{"role": "system", "content": f"Conversation summary: {summary}"}] + tail

    The caller must provide count_tokens and summarize functions. The former can use the tokenizer corresponding to the chosen model, and the latter can call the same model to generate a summary. Note that the summary itself consumes tokens, so its maximum length should be controlled.

    4.3 Token Bucket Rate Limiting

    Quota control needs to be evaluated at the request entry point. The token bucket is a common algorithm that allows a certain degree of burst traffic while limiting the long-term average rate.

    1. import time
    2. from dataclasses import dataclass, field
    3. @dataclass
    4. class TokenBucket:
    5. capacity: float # Bucket capacity, i.e., max burst tokens allowed
    6. refill_per_sec: float # Tokens replenished per second
    7. tokens: float = field(init=False)
    8. last: float = field(default_factory=time.monotonic)
    9. def __post_init__(self):
    10. self.tokens = self.capacity
    11. def consume(self, n: float) -> bool:
    12. now = time.monotonic()
    13. elapsed = now - self.last
    14. self.tokens = min(self.capacity, self.tokens + elapsed * self.refill_per_sec)
    15. self.last = now
    16. if n <= self.tokens:
    17. self.tokens -= n
    18. return True
    19. return False

    When a request arrives, estimate the input and expected output tokens, then call consume. If it returns False, return a clear rate-limit status code (e.g., HTTP 429) with a suggested retry time, rather than failing directly.

    In multi-instance deployments, the token bucket state must be stored in a shared storage; otherwise, each instance counts independently, effectively multiplying the actual quota.

    5. Reliability and Degradation Strategies

    5.1 Clear Error Semantics

    Quota triggers, service busy states, and model failures should return different error messages. Categorizing all failures as “Server Busy” prevents users from knowing whether to wait, reduce input, or switch approaches. Error codes, reasons, and recovery times should all be provided.

    5.2 Exponential Backoff and Jitter

    When clients encounter rate limiting or temporary faults, they should adopt an exponential backoff with random jitter retry strategy to avoid a large number of clients retrying simultaneously and causing a secondary impact.

    1. import random
    2. import time
    3. def call_with_backoff(request_fn, max_retries: int = 5, base: float = 0.5, cap: float = 30.0):
    4. for attempt in range(max_retries):
    5. try:
    6. return request_fn()
    7. except Exception:
    8. if attempt == max_retries - 1:
    9. raise
    10. delay = min(cap, base * (2 ** attempt))
    11. time.sleep(random.uniform(0, delay)) # full jitter

    5.3 Circuit Breaking and Degradation

    When a dependency fails continuously, a circuit breaker can temporarily stop forwarding requests, giving the downstream time to recover. Degradation plans can include disabling non-core features, shortening the context window, or switching to a smaller model for simple requests. Degradation should be communicated to users via a status page or UI, not done silently.

    6. User Experience and Trust

    6.1 Conversations as State: Needs to be Exportable

    Many users treat long-term conversations as important work records or personal archives. For these users, suddenly losing history causes real loss. Reasonable approaches include notifying users of rule changes in advance, providing conversation export features, and offering archival methods. Export formats can be plain text or structured JSON for easy migration.

    6.2 Predictable Rules

    Quota values, effective times, and reset cycles should be public. Users can only make reasonable arrangements if they can estimate their usage. Frequent or sudden rule adjustments undermine user trust in the service.

    6.3 Boundary Prompts for Specific Scenarios

    Some users may use general conversation tools for emotional support or mental health-related communication. In such scenarios, the system should clearly define its capability boundaries, prompt users to seek professional help at appropriate times, and provide available assistance channel information. Technical solutions cannot replace professional mental health services, and product design should reflect this.

    7. Implementation Checklist

    When designing quotas or resource management plans for long-conversation services, verify each item against this checklist:

    • Is the token used as the metering unit instead of request count?
    • Is the single input length limit determined based on measured memory and latency data?
    • Is there a clear resource basis for the retention duration of idle sessions?
    • Are history compression strategies (sliding window, summarization, external retrieval) defined and tested?
    • Does the rate limit response include a status code, reason, and suggested retry time?
    • Is the counting state in a multi-instance environment centrally stored?
    • Do clients implement backoff retries with jitter?
    • Are rule changes notified in advance with data export options provided?
    • Are high-traffic degradation plans operational and communicated to users via the UI?

    Resource constraints are objective limitations of LLM services. Translating them into clear rules, reliable engineering implementations, and transparent user communication is the foundation for long-term stable service operation.