LLM Inference in Its Second Half: Quota Control and the Economics of Retention
In the early stage of the LLM market, competitiveness was measured by parameter counts, benchmark scores, and inference speed. As the market enters its second half, capital increasingly cares about whether users stay and whether the cost of serving each one stays under control. This article examines retention as an engineering discipline behind LLM inference services, covering four core challenges—rate limiting, quota and billing accuracy, capacity planning, and service stability—along with the observability metrics needed to catch quota errors and capacity bottlenecks before users complain. It includes working examples of token-bucket rate limiting and atomic quota deduction, and closes with a discussion of how API gateways, container platforms, message queues, and monitoring services fit together as a governance pattern for inference services.
1. From a Performance Race to a Retention Race: The Investor’s View
Early in the LLM industry, competitiveness was measured by parameter counts, benchmark scores, and inference latency. In the second half of the market, however, investors care less about “how strong the model is” and more about “whether users stay, and whether the cost of serving each user is controllable.”
The logic behind this shift is straightforward. Model capabilities are gradually converging among leading vendors, and the marginal cost of switching providers is very low. A single rate-limiting incident, a mis-deducted quota, or an anomalous quota spike can be enough to drive a paying customer away. From a capital-efficiency standpoint, small movements in retention often move business valuation more than marginal gains on performance metrics.
Retention, of course, cannot be achieved by declaring “user experience first.” It ultimately comes down to a set of concrete engineering capabilities: whether rate limits are reasonable, whether quota metering is accurate, whether there is enough compute, and whether the service stays up. Each layer is broken down below.
2. Four Core Engineering Challenges Behind Retention
2.1 Rate Limiting: Prevent Abuse Without Punishing Legitimate Users
Rate limiting is the immune system of an inference service. It stops a few users from crowding everyone else out of shared compute and absorbs traffic bursts before they overwhelm the backend. But if the policy is too tight, legitimate users get rejected constantly; if it is too loose, the system is unprotected.
Two algorithms are common in practice:
- Token bucket — permits a degree of burst traffic while capping the average rate, which suits interactive inference workloads.
- Leaky bucket — releases requests at a constant rate, producing smoother output and shielding downstream compute from momentary spikes.
For LLM workloads, the unit of limiting is usually not the request but the token, because the compute cost of individual requests varies enormously. A sound approach enforces both requests per minute (RPM) and tokens per minute (TPM).
import timeimport threadingclass TokenBucket:"""Token bucket limiter: allows bursts while constraining the average rate"""def __init__(self, capacity, refill_rate):self.capacity = capacity # bucket capacity, i.e. the burst ceilingself.tokens = capacity # tokens currently availableself.refill_rate = refill_rate # tokens replenished per secondself.last = time.monotonic()self.lock = threading.Lock()def acquire(self, tokens=1):with self.lock:now = time.monotonic()# Smoothly refill tokens based on elapsed timeelapsed = now - self.lastself.tokens = min(self.capacity,self.tokens + elapsed * self.refill_rate)self.last = nowif self.tokens >= tokens:self.tokens -= tokensreturn Truereturn False
The key point: limits should be configured per subscription tier, and when a request is rejected, the error should tell the user clearly when they can retry rather than refusing silently.
2.2 Quota and Billing Accuracy: One Miscalculation Can Cost a Customer
The problems that surface repeatedly in practice are “abnormal quota consumption” and “incorrect quota accounting.” These expose an aspect of LLM services that is easy to overlook: the precision of metering.
Token counting is inherently imprecise—prompt tokenization, interrupted streaming output, and request retries can all cause over- or under-counting. Once a quota system is built on unreliable counting, users’ trust in what they pay for breaks down.
Three principles apply:
- Store quotas in integer smallest units to avoid floating-point accumulation error;
- Deduct atomically so concurrent requests cannot over-deduct or miss a deduction;
- Keep a traceable metering ledger so both the user and support can reconcile charges.
def charge_quota(user_id, prompt_tokens, completion_tokens, unit_price):"""Charge for tokens and deduct the quota.Quotas are stored as integers in the smallest billing unit to avoidfloating-point drift; atomic decrement prevents concurrent over-deduction."""billable_tokens = prompt_tokens + completion_tokenscost_in_li = billable_tokens * unit_price # integer arithmetic throughoutkey = f"quota:{user_id}"remaining = redis_client.decrby(key, cost_in_li) # atomic decrementif remaining < 0:# Trigger compensation: roll back this charge, raise an alert, or# stop admitting further requestshandle_overdraft(user_id, key, cost_in_li)# Append an immutable ledger entry for later reconciliation and auditappend_ledger(user_id, prompt_tokens, completion_tokens, cost_in_li)return remaining
When a billing defect appears, proactive compensation retains users far better than a reactive apology. Rather than waiting for complaints to pile up, detect the anomaly through monitoring and automatically roll back and restore the quota as early as possible.
2.3 Capacity Planning: Rate Limiting Is Not a Cure-All
Suspending new subscriptions because compute is insufficient is a symptom of capacity planning lagging behind growth—and even with rate limiting in place, that gap turns into widespread service degradation.
Sound capacity governance should include:
- Elastic scaling: use the horizontal scaling capabilities of container platforms to adjust instance counts based on queue depth and GPU/accelerator utilization;
- Tiered queuing: schedule requests by priority through a message queue, giving paying and free users different queue levels;
- Capacity forecasting: extrapolate from historical call curves to scale out ahead of demand instead of firefighting in the moment.
It is worth stressing that compute has a cost. The commercial essence of retention is maximizing service availability while keeping unit cost under control. Rate limiting and scheduling policies should therefore balance cost against experience, rather than pursuing “infinite scaling.”
2.4 Service Stability: Stability Is Retention
For an LLM service that streams output, a dropped connection or a 5xx response reads to the user as “the product is down.” Stability work typically includes:
- Graceful degradation: return a simplified response or a friendly message under overload instead of failing outright;
- Idempotency and retries: distinguish requests that are safe to retry so that retry storms do not cause double charges;
- Timeouts and circuit breaking: set sensible timeouts on upstream dependencies so slow requests do not drag down the whole call chain.
3. Observability: Finding Problems Before the Apology
All of the capabilities above need a unified monitoring and alerting layer to close the loop. The core metrics should include at least:
| Metric | Meaning | Why it matters for alerting |
|---|---|---|
| Rate-limit hit rate | Share of rejected requests | A high value indicates unreasonable capacity or limit settings |
| Quota deviation rate | Gap between ledger entries and expected charges | Surfaces metering errors early |
| Queue latency P99 | How long requests wait | Early warning of a compute bottleneck |
| Error rate | Share of 5xx and timeouts | Reflects overall service health |
| Cost per token | Cost divided by billed tokens | Assesses commercial sustainability |
Feeding these metrics into monitoring and alerting, and consolidating them into a log service for long-term retention, is what makes it possible to detect anomalies before users file complaints. For a mature inference service, the focus of operations is not “apologize after things break” but “keep things from breaking.”
4. A Retention Engineering Perspective from Baidu AI Cloud
Rate limiting, metering, elastic scaling, and monitoring are, taken together, a governance pattern for inference services. In practice at Baidu AI Cloud, requirements like these are typically supported by the combined capabilities of general-purpose cloud products such as API gateways, container platforms, message queues, log services, and monitoring and alerting, helping developers build LLM applications that are highly available and cost-controlled. The central idea remains the same: use engineering to turn “retention” into a measurable, optimizable, sustainable metric rather than leaving it at the level of a slogan.
5. Conclusion
In the second half of the LLM race, the deciding factor has shifted from benchmark scores to retention. Behind retention sit concrete engineering questions: whether rate limits are reasonable, whether quotas are calculated accurately, whether compute keeps pace, and whether the service holds up.
For developers, rather than chasing marginal improvements in model parameters, it is more valuable to lay the foundation of inference service governance first: use reliable rate limiting to protect the system, precise metering to earn trust, elastic capacity to control cost, and observability to eliminate problems before they occur. Ultimately, from the investor’s perspective, getting users to want to stay is the real technical moat of an LLM product.
