High-Concurrency Stability Practices for Large Model APIs

    This article explains how to keep large model APIs stable under high concurrency. It covers why token throughput at the trillion-per-week scale turns availability into a system resilience problem, how capability aggregation expands the failure domain, and how to build a unified gateway, capacity planning based on peak multipliers, traffic shaping with token buckets and concurrency gates, layered degradation and fallback, token-level observability, and incident drills. A reference architecture on Baidu AI Cloud is included.

    1. The Core Issue: High Call Volume Is Itself a Stress Test

    Public statistics from an aggregation platform show that a single model can reach tens of trillions of token calls in one week, ranking first globally. Meanwhile, a model provider’s status records show 8 service interruptions since October of that year, covering the chat service and two API tiers of different specifications. One outage lasted more than 4 hours and simultaneously limited web, mobile, and API access. In early November, a localized evening interruption triggered widespread discussion again.

    Put together, these facts point not to a verdict on any single provider, but to a more universal engineering proposition: once token throughput enters the trillions-per-week range, the main constraint on service availability shifts from model quality to system resilience. The higher the call volume, the greater the probability that long-tail requests, traffic spikes, and dependency jitter are amplified, and any single point of insufficient capacity can produce an exponentially large blast radius.

    Another notable point in time: in mid-November, a provider folded conversational capabilities such as deep thinking, web search, and file input into the existing API as parameter switches, and split underlying capabilities such as speech, OCR, and ASR into separate endpoints that can be called individually or in combination. This means developers can replicate a complete conversational application through a single entry point. Capability aggregation brings convenience, but it also expands the failure domain from “one endpoint” to “a chain of capabilities” — jitter in any sub-capability propagates along the call chain.

    2. Translating “Capability Aggregation” into Architecture Constraints

    Once capabilities are exposed as a mix of parameters and separate endpoints, the architecture must acknowledge three things:

    1. More dependencies: a single request combining deep thinking, web retrieval, and file parsing is a series of sub-calls. End-to-end latency is roughly the sum of each segment, and availability is roughly the product of each segment.
    2. More failure modes: timeouts, rate limiting, content moderation rejections, upstream 5xx errors, and interrupted streaming connections all require different handling and cannot be covered by one retry policy.
    3. More complex cost accounting: input/output tokens, retrieval counts, speech duration, and page counts are metered separately, so capacity planning cannot look at tokens alone.

    The recommendation is therefore to introduce a unified model access layer (Gateway) on the business side and absorb the differences there:

    1. Client -> Business gateway (auth/quota/audit)
    2. -> Access layer (routing/protocol adaptation/token metering)
    3. -> Capability orchestration (thinking/retrieval/file/speech as separate sub-calls)
    4. -> Upstream model services (multiple sources possible)
    5. -> Observability and feedback (logs/metrics/traces)

    3. Capacity Planning: Estimate the Peak First, Then Add Headroom

    Do not buy capacity by dividing average daily tokens by 86400; estimate with a peak multiplier. A practical formula:

    1. Peak QPS ≈ average daily requests / 86400 × peak factor (3~5 recommended)
    2. Peak tokens/sec ≈ peak QPS × (average input tokens + average output tokens)
    3. Required concurrency ≈ peak tokens/sec × average request duration (s) / per-connection throughput

    Supporting actions: set a token budget per business line rather than only a QPS limit; schedule heavy tasks such as long-context processing and batch summarization into off-peak windows; set a hard cap on output length so a few very long generations do not consume most of the quota.

    4. Traffic Shaping: Two-Layer Governance at the Client and the Gateway

    • Token bucket rate limiting: the gateway enforces limits separately per tenant, per endpoint, and per capability, returning an identifiable error code when a limit is exceeded instead of silently queuing.
    • Concurrency gate: use a semaphore to cap in-flight requests and prevent an infinitely growing queue from causing a cluster-wide timeout avalanche.
    • Request merging and caching: apply semantic caching to identical system prompt prefixes and repeated questions about the same document; a cache hit skips the upstream call.
    • Backoff retry: use exponential backoff with jitter only for idempotent, explicitly retryable errors; never blindly retry timeout errors.
    1. # Example: exponential backoff with jitter, for retryable errors only
    2. import random, time
    3. RETRYABLE = {429, 500, 502, 503, 504}
    4. def call_with_backoff(fn, max_attempts=3):
    5. for i in range(max_attempts):
    6. try:
    7. return fn()
    8. except UpstreamError as e:
    9. if e.status not in RETRYABLE or i == max_attempts - 1:
    10. raise
    11. time.sleep(min(8, 2 ** i) + random.random())

    5. Degradation and Fallback: Turning Unavailable into Partially Available

    Under heavy load, the correct goal is not “everything succeeds” but “the core path does not fail”. A layered strategy:

    1. Capability degradation: turn off deep thinking and web search and keep only basic chat; if file parsing fails, return a plain-text follow-up question first.
    2. Model degradation: route to a smaller or lower-latency backup model, trading a little quality for success rate.
    3. Result fallback: when retrieval is unavailable, answer from cached knowledge and explicitly label that “information may be outdated”.
    4. Asynchronous processing: convert long tasks to a submit-then-poll/callback model and use a message queue to shave peaks, avoiding long connections occupying all concurrency.
    1. {
    2. "feature_flags": {
    3. "deep_thinking": "off_when_load>0.8",
    4. "web_search": "cache_only",
    5. "file_parse": "async",
    6. "fallback_model": "small_fast"
    7. }
    8. }

    6. Observability: Monitor Tokens, Not Just Requests

    Essential metrics: end-to-end P50/P95/P99 latency, time to first token, stream interruption rate, rate-limit hit rate, token consumption rate per tenant, success rate of each sub-capability, and the distribution of upstream error codes. Logs and traces must span every sub-call within a request to determine whether retrieval or generation is slow. Alerts should be tiered: error rate and time to first token trigger urgent alerts, while abnormal token consumption rates trigger capacity warnings.

    7. Incident Reviews and Drills

    An interruption lasting several hours usually exposes process problems rather than a single point of failure. Recommended to establish: status page and user announcement templates, a cross-team command chain, rollback and traffic-switching plans, and weekly dependency fault-injection drills (deliberately making a sub-capability unavailable), with drill results fed back into the capacity model.

    8. Using the Capability Combination on Baidu AI Cloud

    To implement the architecture above on Baidu AI Cloud, general-purpose capabilities can be used directly: the container platform hosts the gateway and orchestration services with elastic scaling, a message queue shaves peaks for long tasks, object storage holds intermediate artifacts from file parsing, log and monitoring/alerting services handle metric collection and tiered notification, and a cache service carries semantic caching and rate-limit counters. On the model side, a unified access layer handles multi-source routing and degradation, avoiding tight coupling between business code and any single upstream.

    Conclusion

    Trillion-scale weekly token call volume shows that demand is real, and 8 interruptions show that resilience must be built at the same time. Making rate limiting, degradation, asynchronous processing, and observability default capabilities is what allows model capabilities to be delivered reliably to end users as capabilities keep aggregating and endpoints keep multiplying.