Free-Tier Quotas Under Compute Constraints: Rate Limiting Practices for LLM Services
This article explains how engineering teams design free-tier quotas for large language model services when compute capacity is limited. It covers why usage limits matter, the four dimensions used to define quotas, common rate-limiting algorithms with a token bucket example, quota configuration, graceful degradation, monitoring, and user-facing error handling.
1. Background: Compute Is the Real Constraint
The long-term goal of a large language model service is usually to raise the ceiling of model capability. Free services for users are a short-term operational tool. As teams push model capability forward, what limits their pace is rarely the choice of direction. It is available compute. Compute determines how many requests can be processed per unit of time, how long each response can be, and whether the service can stay responsive during peak hours.
For engineering teams, this means a free-tier policy cannot look only at user growth. It also has to account for the resource cost of each request. A multi-turn conversation with a long context can cost several times as much as a short question. If free users have no usage boundaries, a small number of high-cost requests can consume most of the resources. Paying users and regular users will then see their experience degrade.
2. Why Free Users Need Limits
Free-tier quotas are usually designed for four reasons.
Cost control. Inference cost scales roughly linearly with the number of generated tokens, and compute resources are consumed continuously as request volume grows. Without a cap, free access makes costs grow unpredictably with the user base.
Service quality. When concurrent requests exceed what the cluster can handle, queuing time rises quickly. Time to first token and total response time both increase. Limits keep traffic within the capacity the system can handle, which protects the core experience.
Abuse prevention. Automated scripts that send bulk requests, inflate usage counts, or generate malicious content consume large amounts of resources without producing legitimate value. Limits are one of the basic tools for curbing this behavior.
Fair allocation. Many types of users share the same resources. A reasonable tiered structure gives regular users a stable baseline experience and helps users with different needs find a usage pattern that fits them.
3. Four Dimensions of Quota Design
Limiting users with a single metric often leaves gaps or penalizes regular users by mistake. In practice, teams usually combine four dimensions.
- Request count. Requests are counted per minute or per day. This is simple to implement and easy to explain to users. However, it does not reflect the cost difference between requests. A short one-line question and a long document analysis count the same.
- Token usage. Usage is measured by the total number of input and output tokens. This is the closest match to actual cost. The drawback is that users find it hard to estimate their consumption, so the interface needs to show remaining quota.
- Concurrency. This limits how many requests one account can have in progress at the same time. It prevents a single user from filling the connection pool and compute queue.
- Model and context limits. Free users can be given access to a smaller model, or be capped on maximum context length and maximum output per request. This reduces the cost of each request at the source.
In a practical design, token usage should be the primary metric. Concurrency and per-request output limits should serve as protective constraints.
4. Common Rate-Limiting Algorithms
A rate-limiting algorithm decides how requests are allowed through or rejected. The four most common algorithms in engineering are described below.
- Fixed window: Requests are counted within each time window, and any request beyond the threshold is rejected. This is the simplest approach, but it can allow roughly double the intended traffic at the boundary between two windows.
- Sliding window: The window is split into smaller time slices. This reduces boundary effects, at a slightly higher computational cost.
- Token bucket: Tokens are added to a bucket at a fixed rate, and each request consumes tokens. The algorithm allows short bursts while limiting the long-term average rate, which makes it a good fit for conversational scenarios.
- Leaky bucket: Requests are processed at a fixed rate, and excess requests are queued or dropped. The output is smoother, but bursty requests are handled more slowly.
For a conversational service on a free tier, the token bucket is usually a good choice. It lets users ask several questions in a row while still limiting the long-term rate. The following is a simplified implementation.
import timeimport threadingclass TokenBucket:def __init__(self, capacity: int, refill_rate: float):self.capacity = capacity # Bucket capacity, which sets the maximum burst sizeself.refill_rate = refill_rate # Number of tokens added per secondself.tokens = float(capacity)self.updated_at = time.monotonic()self.lock = threading.Lock()def acquire(self, cost: int = 1) -> bool:with self.lock:now = time.monotonic()elapsed = now - self.updated_atself.tokens = min(self.capacity, self.tokens + elapsed * self.refill_rate)self.updated_at = nowif self.tokens >= cost:self.tokens -= costreturn Truereturn False
In production calls, cost can be set to the estimated token count of the request, so rate limiting matches actual resource consumption. In a production environment, the bucket state should be stored in shared storage to support multi-instance deployments.
5. Configuring Quota Policies
Hard-coding quota parameters in business logic means every adjustment requires a new release. A safer approach is to abstract the policy into configuration and load it according to the user’s tier. The values in the example below only illustrate the structure. Actual values should be determined through cost estimates and capacity planning.
FREE_TIER_POLICY = {"daily_tokens": 200_000, # Daily token limit"max_output_tokens": 1024, # Maximum output tokens per request"max_concurrency": 1, # Maximum concurrent requests"model_tier": "standard", # Model tier available}def check_quota(used_today: int, requested_tokens: int, policy: dict) -> tuple[bool, str]:if used_today + requested_tokens > policy["daily_tokens"]:return False, "quota_exceeded"return True, "ok"
Configuration offers three benefits. First, parameters can be adjusted by time period or region in a gradual rollout. Second, it is easier to audit how resources are allocated across tiers. Third, when capacity changes, operations staff can respond without modifying code.
6. Tiered Degradation Instead of Hard Cutoffs
Rejecting requests outright is the bluntest way to handle overload. Mature services usually design multi-level degradation paths that protect resources while keeping the service as available as possible.
- Normal service: When quota remains and resources are free, the request is served at the standard specification.
- Queueing: During peak hours, requests are placed in a queue, and the user is told the estimated wait time.
- Downgrade: The system automatically switches to a smaller or faster model, or lowers the maximum output length.
- Asynchronous processing: For long document tasks, users submit a request and retrieve the result later.
- Clear rejection: When quota is exhausted or abuse is detected, the system returns a clear error message and the time when access resumes.
The degradation order should be documented in the operations runbook and verified through drills. This avoids making decisions on the fly during an incident.
7. Metering and Observability
The reliability of a quota system depends on accurate metering. At minimum, teams should monitor the following metrics:
- The distribution of daily token consumption per user, to identify accounts with unusually high usage;
- Percentile latencies for time to first token and total response time, such as P95 and P99;
- Queue length and rejection rate, to judge whether limits are too tight or too loose;
- The actual cost and capacity utilization of each model tier.
These metrics can be collected through a logging service, and alert thresholds can be set in a monitoring system. For example, if the rejection rate exceeds a set threshold for ten minutes, a notification can be sent so that operations and engineering teams can decide together whether the policy needs adjustment.
8. User Communication and Error Design
Quota limits directly affect the user experience, so how they are communicated matters as much as how they are implemented.
- Show remaining quota and the reset time in the interface so users can plan their usage;
- Return the standard HTTP 429 status code, and use the
Retry-Afterresponse header to indicate how many seconds to wait; - Error messages should explain the cause and the next step, rather than returning a vague failure message;
- For users approaching their limit, send an early reminder to reduce frustration caused by sudden interruptions.
9. Implementation Checklist
When rolling out a free-tier quota policy, teams can follow these steps:
- Estimate the average and percentile cost of a single request, and define the resource cost of each token;
- Use capacity planning to set quota limits for each tier, and keep headroom for peak demand;
- Choose a combined strategy that uses token usage as the primary metric, with concurrency and output limits as secondary constraints;
- Implement rate limiting with a token bucket or sliding window, and store state in shared storage;
- Manage policies as configuration to support gradual rollouts and fast rollbacks;
- Set up monitoring metrics and alert rules, and review regularly how well quotas match costs;
- Design clear error codes and user messages to reduce confusion and complaints.
A free quota is not a one-time decision. It needs continuous adjustment as compute, costs, and user behavior change. Turning limits into rules that are measurable, configurable, and explainable is what keeps a service stable under limited resources.
