Retry Storms and System Resilience: Why Large-Scale AI Service Outages Escalate

    When a critical dependency fails in a large distributed system, retries from AI applications and automated clients can amplify the incident into a retry storm. This article explains how downstream failures are amplified, how retry storms form, and how to design safer retry policies, idempotency, circuit breaking, rate limiting, isolation, gradual recovery, observability, AI-specific guardrails, and failure drills.

    In large distributed systems, an infrastructure failure rarely appears only as “one API is temporarily unavailable.” When a critical link in identity authentication, domain name resolution, network access, messaging, data storage, or compute scheduling fails, the failure can spread rapidly along dependency chains and eventually become widespread service unavailability.

    A particularly important concern is that AI applications and automated clients are becoming new traffic amplifiers. They often have characteristics such as high concurrency, long call chains, automated execution, and continuous invocation. When an underlying service fails, an upper-layer application that uses a simplistic “retry on failure” strategy may continue to generate a large number of requests before the original failure has recovered. This phenomenon, in which retry behavior suddenly concentrates and amplifies traffic, is commonly called a retry storm.

    Why Downstream Systems Amplify Upstream Failures

    Suppose a core dependency service originally receives 10,000 requests per second, there are 1,000 callers, and each caller sends an average of 10 requests per second. When the dependency service is briefly unavailable, if every caller retries once immediately after a failure, request volume may instantly double. If each request continues to retry multiple times, the theoretical request volume can grow rapidly.

    A more complex situation is that one user request often corresponds to multiple internal operations. For example:

    1. The ingress layer receives the request.
    2. The identity verification service validates permissions.
    3. The configuration service reads runtime parameters.
    4. The inference or compute service processes the task.
    5. The data service writes the result.
    6. The messaging system delivers follow-up events.

    A failure at any step may trigger the upper layer to resubmit the entire task. If every layer has its own independent retry mechanism, the number of retries is not simply additive; it may show a multiplicative effect. One underlying timeout may cause multiple intermediate services to execute repeatedly, ultimately creating a large amount of无效 traffic.

    AI applications also have several special characteristics:

    • A single task may run for a long time, and timed-out requests can occupy connections and threads for an extended period.
    • One request may trigger multiple tool calls, retrieval operations, or background tasks.
    • Automated clients often lack human intervention and continue running.
    • After a task fails, it may be retried simultaneously by the scheduler, the business layer, and the client.
    • Steps generated by large models may increase the length of the call chain and the number of dependencies.

    Therefore, AI is not necessarily the direct cause of a failure, but it can change the traffic pattern of the failure and make the system more likely to move from “local anomaly” to “resource exhaustion.”

    How Retry Storms Form

    A retry storm usually consists of four stages.

    The first stage is dependency abnormality. An underlying service experiences packet loss, connection failure, response timeout, insufficient resources, or service switching. At this point, callers can only see error codes, timeouts, or connection interruptions, and may not be able to determine whether the failure is transient or persistent.

    The second stage is concentrated client retries. A large number of clients send a second request within approximately the same time window. If the retry interval is fixed, for example once every second, all requests form a clear synchronized pulse.

    The third stage is resource exhaustion. Retry requests consume connection pools, thread pools, coroutines, memory, queues, and logging capacity. Even if the underlying dependency has begun to recover, new upper-layer traffic may overload it again.

    The fourth stage is cascading spread. The dependency service’s responses become even slower, callers consider requests failed and continue retrying, and the failure expands from a single point of unavailability to simultaneous degradation across multiple services, ultimately appearing as full-chain congestion.

    There is a common misconception here: many teams believe that “setting a retry count” solves the problem. In practice, a retry count only controls how many times a single request may be repeated. It does not address core questions such as whether a request should be retried, when it should be retried, which layer should retry it, and how the system should be protected during retries.

    Designing Retry Policies Correctly

    Retry Only Errors That Are Suitable for Retry

    Not all errors are worth retrying. Temporary network interruptions, connection resets, and temporary service overload may recover after waiting. In contrast, parameter errors, permission failures, missing resources, and business rule rejections will not succeed even if the request is sent repeatedly.

    Therefore, systems should establish clear error classifications:

    • Recoverable network errors: limited retries may be allowed.
    • Temporary overload: combine backoff with rate limiting.
    • Request timeout: determine whether the server has already executed the operation.
    • Parameter or permission errors: usually should not be retried.
    • Explicit business rejection: return directly or enter a manual handling process.

    Use Exponential Backoff and Random Jitter

    Fixed-interval retries easily create synchronized requests. A more reasonable approach is exponential backoff, which gradually increases the wait time after consecutive failures, combined with random jitter to prevent a large number of clients from starting the next round of requests at the same time.

    The logic can be illustrated as follows:

    1. wait_time = min(max_wait_time,
    2. base_wait_time * 2^retry_count + random_jitter)
    3. if error_type is non-recoverable:
    4. end immediately
    5. if max_retries has been reached:
    6. move to degradation or failure queue
    7. else:
    8. wait and try again

    Random jitter does not mean extending the wait indefinitely. Instead, it spreads different requests across a time window. This reduces instantaneous peaks and helps the underlying service recover gradually.

    Control Retry Budgets

    A retry budget should be set for each request, each user, each tenant, and each service. Budgets can be calculated by count, time, or total consumption. For example, a request may be allowed at most two retries, a task may run for at most 30 seconds, and a tenant may submit only a certain number of compensation tasks per unit of time.

    The purpose of a retry budget is to make explicit how many extra resources the system is willing to spend to improve the success rate. Without a budget, retries can become unbounded resource competition.

    Avoid Duplicate Retries Across Layers

    One of the most dangerous designs in distributed systems is when the client, gateway, business service, task scheduler, and message consumer each implement retries without a unified boundary.

    For example:

    • The client retries three times after a failure.
    • The gateway retries twice on upstream timeout.
    • The business service retries three times when calling a dependency.
    • The message consumer redelivers a message after processing fails.
    • A scheduled task resubmits a task after detecting failure.

    In an ideal case, one task may be executed dozens of times, and each layer is unaware that other layers have already retried. Solutions include:

    1. Define retry ownership clearly. Synchronous requests are usually retried a limited number of times by the layer closest to the user, and internal services should not stack unlimited retries.
    2. Pass request context. Through request identifiers, deadlines, and remaining retry budgets, downstream services can know how many resources the current task has already consumed.
    3. Distinguish synchronous and asynchronous scenarios. Synchronous APIs should fail fast or degrade; asynchronous tasks can enter a delayed queue and be managed centrally by a scheduler.
    4. Establish end-to-end timeouts. Every layer should obey the overall deadline instead of recalculating a full timeout independently.

    Idempotency Is the Foundation for Safe Retries

    The business problem most easily caused by retries is that the same operation is executed multiple times. Examples include charging a payment, creating an order, sending a notification, writing data, or triggering an external action. If an API is not designed for idempotency, a client cannot determine after a network timeout whether the server has already processed the request successfully, which may cause duplicate execution.

    Common practices include:

    • Generate a unique request identifier for each business operation.
    • Store the mapping between request identifiers and processing results on the server.
    • Return the original result directly when the same identifier arrives again.
    • Use unique constraints or conditional updates for data writes.
    • Add a state machine for irreversible operations to prevent duplicate transitions.

    It is important to note that idempotency does not mean “duplicate requests never have any impact.” It requires the system to recognize the same business intent and ensure that the intent produces at most one effective result, or that multiple executions produce a consistent result.

    Use Circuit Breaking, Rate Limiting, and Isolation to Contain Failures

    When a dependency service continues to fail, callers should not continue accessing it at normal traffic levels. A circuit breaker can temporarily cut off requests based on failure rate, timeout rate, or the number of consecutive errors, and then gradually probe recovery after a cooling-off period.

    A circuit breaker usually has three states:

    • Closed: requests pass through normally.
    • Open: fail fast and stop accessing the abnormal dependency.
    • Half-open: allow a small number of probe requests and decide whether to recover or continue breaking based on the results.

    Rate limiting is used to control the number of requests entering the system. Rate limiting should not apply only to total traffic; it can also be subdivided by user, tenant, API, task type, and resource class. For AI applications, it should also distinguish interactive requests, batch tasks, and background automation tasks to prevent low-priority tasks from crowding out core resources.

    Isolation prevents different businesses from sharing the same set of resources. For example, use separate queues for different tenants, separate thread pools for different tasks, and reserve connections and compute resources for high-priority requests. In this way, even if a certain type of automation task becomes abnormal, it will not drag down the entire system.

    Protect the Recovery Phase as Well

    Many systems take load-shedding measures during a failure but fail again after the service recovers. The reason is that a large number of backlogged requests are released simultaneously at the moment of recovery, creating a “recovery surge.”

    Therefore, the recovery process should use a gradual strategy:

    1. Restore basic dependencies and critical control planes first.
    2. Gradually allow a small amount of probe traffic.
    3. Observe error rates, latency, and resource usage.
    4. Restore different business levels in stages.
    5. Throttle and consume backlogged tasks in batches.
    6. Avoid clearing all delayed requests at once.

    For messaging and task systems, it is not enough to focus only on whether the backlog is decreasing. It is also necessary to observe processing speed, failure ratio, duplicate execution rate, and downstream capacity. Blindly increasing the number of consumers may simply shift pressure from the queue to the database or external dependencies.

    Build Failure-Oriented Observability

    To identify retry storms, checking error logs alone is far from sufficient. At a minimum, the following metrics should be monitored:

    • Original request volume and retry request volume.
    • Proportions of different error types.
    • Average retry count and retry success rate.
    • Number of timed-out requests.
    • Connection pool, thread pool, and queue usage.
    • Circuit breaker state changes.
    • Number of rate-limit rejections.
    • Duplicate task executions and idempotency hits.
    • Traffic slope after service recovery.
    • Resource consumption by tenant and business level.

    Logs should also record request identifiers, parent-child call relationships, retry sequence numbers, deadlines, and error classifications. Through distributed tracing, it is possible to determine whether one user request has been repeatedly amplified by multiple services, and whether the failure occurred at the ingress, in a dependency, or during recovery.

    Additional Governance for AI Applications

    AI systems should not leave all failures to the model or automated agents to handle on their own. A more reliable approach is to establish clear operating boundaries:

    • Set a maximum execution duration for a single task.
    • Limit the number of tool calls and concurrency.
    • Assign risk levels to different actions.
    • Require human confirmation for high-cost operations.
    • Move failed tasks into an observable compensation queue.
    • Prevent the model from repeatedly performing the same action based on error results.
    • Set a unified access budget for external dependencies.
    • Provide a global pause switch for automated clients.

    In particular, when dependency services experience widespread abnormalities, the system should have a “stop-loss mode”: pause non-critical tasks, reduce batch processing concurrency, disable high-cost features, preserve core read operations, and return understandable degradation results to users.

    Run Failure Drills Before Launch

    Stability cannot rely only on design documents; it also needs to be validated through drills. Test scenarios can include:

    • A core dependency is completely unavailable.
    • Dependency service response latency increases significantly.
    • The network experiences intermittent packet loss.
    • Errors and timeouts alternate.
    • Messages are delivered repeatedly.
    • Backlogged requests are released in a concentrated burst after service recovery.
    • A single tenant generates abnormally high concurrency.
    • Automated tasks show a tendency toward infinite loops.

    The focus of a drill is not to prove that the system will never fail, but to confirm whether it can quickly rate-limit, isolate, degrade, alert, and recover when failure occurs. Each drill should produce a postmortem report recording which retry policies were effective, which resources were exhausted first, which monitoring failed to detect the problem in time, and whether a second impact occurred during recovery.

    Conclusion

    The impact of a large-scale outage often comes not only from the failure source itself but also from how the system behaves in the face of failure. Uncontrolled retries amplify traffic, a lack of idempotency amplifies business losses, multi-layer timeouts extend resource occupation, and concentrated release during recovery can cause an already fragile system to collapse again.

    For developers and enterprises, a truly reliable system is not one that “always succeeds,” but one that can control the scope of impact, prevent failure from spreading, and recover gradually in a predictable way when dependencies are abnormal, the network fluctuates, and services degrade. By unifying retry policies, using end-to-end timeouts, designing for idempotency, applying circuit breaking and rate limiting, isolating resources, recovering gradually, and improving observability, intelligent applications can remain controllable, diagnosable, and sustainable in complex infrastructure environments.