Peak and Off-Peak Pricing for LLM Inference: How It Works and How to Adapt Your Architecture

    This article explains why large language model (LLM) inference billing is shifting from subsidized, flat-rate pricing toward time-based pricing similar to public utilities, and what that change means for developers. It covers the three core shifts developers need to make—treating unit price as only one cost variable, viewing latency and cost as tradeable, and separating capacity planning from cost optimization—followed by practical architecture responses such as request tiering and routing, batching, asynchronous processing with message queues, multi-level caching, and elastic scaling with graceful degradation. It also outlines an engineering loop for cost governance and common pitfalls to avoid, helping teams keep bills predictable as pricing mechanisms evolve.

    1. From Subsidy-Driven to Utility-Style Billing: What Is Really Changing

    Early LLM services commonly used low-barrier or even subsidized pricing to rapidly grow their developer base and accumulate usage scenarios. Once call volume enters a phase of steady growth, the provider’s cost structure shifts from being dominated by R&D amortization to being dominated by operational expenses such as compute and electricity. Billing then moves closer to that of a mature public utility: prices differentiated by time of day and by the form of resource usage.

    Time-of-use pricing is a well-established practice in fields like electricity and cloud resource rental. Its core purpose is not to “raise prices” but to use price signals to redistribute demand along the time axis. For inference services, this is especially natural, for three reasons:

    • Load has pronounced tidal patterns. The peak-to-trough ratio between working hours and nighttime lulls can often reach several times, and during off-peak periods a large number of accelerators sit at low utilization.
    • Electricity and cooling make up a relatively high share of inference cost, and the grid itself has peak-to-trough price differences.
    • Elastic supply has a physical ceiling. Scaling out requires procurement and delivery lead time, so in the short term you can only smooth peaks through scheduling.

    Therefore, changing a “flat unit price” into “high price at peak, low price at trough” essentially makes scarcity explicit: requests willing to wait get a price discount, while latency-sensitive requests pay a premium.

    2. Three Mindsets Developers Need to Rebuild

    2.1 Unit Price Is No Longer the Only Cost Variable

    Under flat pricing, cost is approximately token count × unit price. Once time-of-use pricing is introduced, an extra time dimension appears in the cost function:

    1. Cost = Σ (tokens_i × price(t_i)) + retry cost + cross-region call cost

    This means that for the same business volume, different scheduling strategies can produce bills that differ by several times.

    2.2 Latency and Cost Become Tradeable

    Most workloads have tiered requirements for “time to first token” and “overall latency”: interactive conversation demands second-level response, while background summarization, batch translation, and offline evaluation can tolerate minute-level latency. Time-of-use pricing provides exactly the economic incentive for this tiering.

    2.3 Plan Capacity for the Peak, Optimize Cost for the Trough

    Peak capacity determines the floor of user experience, while trough utilization determines gross margin. The two need to be designed separately, rather than forcing the same synchronous call path to handle both.

    3. Practical Architecture Responses

    3.1 Request Tiering and Routing

    Tag requests at the gateway layer and select different service tiers based on business tolerance:

    1. # Example: pick a service tier based on business tolerance
    2. def pick_service_tier(req):
    3. if req.user_interactive and req.max_latency_ms <= 1500:
    4. return "priority" # callable at peak too, highest cost
    5. if req.deadline_minutes <= 10:
    6. return "standard"
    7. return "batch" # can queue for a long time, gets off-peak price

    The key point is that tiering must be driven by business semantics rather than left to the caller’s “own judgment”; otherwise all requests get marked high priority and the price signal breaks down.

    3.2 Batching and Request Coalescing

    Inference throughput is significantly affected by batch size. Aggregating multiple small requests into a batch can raise output per unit of compute. A common engineering approach is to introduce a short “batching window”:

    1. # Example: batching with a timeout and a capacity limit
    2. class Batcher:
    3. def __init__(self, max_size=32, window_ms=50):
    4. self.buf, self.max_size, self.window = [], max_size, window_ms
    5. def add(self, item):
    6. self.buf.append(item)
    7. if len(self.buf) >= self.max_size:
    8. return self.flush()
    9. return None # wait for the window to expire, then submit together

    If the window is too small, batches cannot form; if it is too large, tail latency rises. It usually needs to be tuned based on load-test results.

    3.3 Asynchrony and Peak Shaving with Message Queues

    Changing synchronous calls into an asynchronous model of “submit a task—return a task ID—get the result via callback or polling,” combined with a message queue as a buffer, can shift peak traffic to off-peak execution. This is the single most directly beneficial change in a time-of-use billing environment.

    3.4 Multi-Level Caching and Semantic Reuse

    • Exact caching: perform key-value caching for identical prompts and parameters; the key must include parameters that affect output, such as model version and temperature.
    • Prefix reuse: shared prefixes such as system prompts and long documents recur across multi-turn requests, and reusing their computed results can significantly reduce repeated computation.
    • Semantic caching: approximately reuse historical Q&A whose similarity exceeds a threshold; this requires setting a similarity threshold and a manual fallback to avoid incorrect reuse.
    1. cache_key = hash(system_prompt || context_prefix || user_query || decode_params)

    3.5 Elastic Scaling and Degradation Plans

    At peak, prioritize success rate; at trough, prioritize cost. It is advisable to prepare three levels of degradation: switch to a model with a smaller parameter size, shorten generation length, and disable non-core polishing and secondary verification steps. Degradation strategies should be configurable, support gradual rollout, and allow automatic rollback.

    4. An Engineering Loop for Cost Governance

    Treat cost as an observable metric rather than a month-end bill:

    • Instrumentation dimensions: business line, call source, service tier, time period, input/output tokens, cache hit rate.
    • Key metrics: cost per request, off-peak traffic share, average batch size, retry rate, cache hit rate, peak rejection rate.
    • Alerts: a continuous drop in off-peak share, a rising retry rate, or an abnormal period-over-period change in cost per request.
    • Optimization cadence: quantify first, then run a gradual rollout, then go full scale; change only one variable at a time to make attribution easier.

    A simplified daily cost calculation snippet:

    1. def daily_cost(records, price_fn):
    2. total = 0.0
    3. for r in records:
    4. total += (r.in_tokens + r.out_tokens) * price_fn(r.ts, r.tier)
    5. total += r.retries * r.in_tokens * price_fn(r.ts, r.tier)
    6. return total

    5. Common Pitfalls

    • Treating time-of-use pricing as simply a price increase, and therefore doing only one thing—“compress usage”—while ignoring the structural savings that scheduling can bring.
    • Converting everything to asynchronous, which degrades the interactive experience; the correct approach is to make only latency-tolerant paths asynchronous.
    • Designing cache keys that omit decoding parameters, causing unstable and hard-to-reproduce outputs.
    • Lacking a peak-capacity plan, so the price signal takes effect but user experience collapses.
    • Having no attribution for cost optimization, making it impossible to tell whether gains came from caching, batching, or traffic shifting.

    6. Conclusion

    The emergence of time-of-use billing marks the transition of LLM services from extensive subsidies to refined operations. For developers, the real capability is no longer “grabbing cheap quota” but reshaping workloads so they can be scheduled, cached, and tiered. Teams that complete this transformation can both meet the latency requirements of interactive scenarios and settle batch-type workloads into low-cost periods, keeping bills predictable as the pricing mechanism changes. If you run the above architecture on general-purpose capabilities from Baidu AI Cloud (such as its container platform, message queue, object storage, log service, and monitoring and alerting), you can reuse its elastic scaling and observability systems and reduce the investment needed to build your own scheduling and cost-accounting components.