Skip to content
/
Suscribirse Subscribe

Detrás del telón hay sistemas, no magia. Arquitectura de software, IA y computación de bajo nivel para las trincheras de producción.

Behind the curtain there are systems, not magic. Software architecture, AI, and systems engineering from the production trenches.

🇪🇸 Leer y usar la calculadora en español aquí

Simulate and architect resilient distributed systems retry policies. Calculate exact per-attempt delays, cumulative worst-case latency, reverse proxy timeout margins (504 Gateway Timeout protection), Full Jitter vs Equal Jitter smoothing, and thundering herd collision risks across microservices and cloud APIs.

1. Retry Policy Parameters

Simulation & Timeout Analysis

Max Cumulative Delay
15.50 s
Worst-case sleep duration
Expected Average Delay
7.75 s
Mean expected latency
Reverse Proxy Timeout Verdict
SAFE BUDGET
Within 60s proxy timeout
Thundering Herd Collision Risk
LOW RISK
Jitter spreads load evenly

Step-by-Step Retry Delay Schedule

Attempt # Deterministic Formula Delay Min Sleep Max Sleep Cumulative Worst-Case

Mathematical Formulas & Jitter Theory

Backoff algorithms calculate interval sleep duration using exponential scaling capped at T_max:

  • Deterministic Base Exponential: Sleep_i = min(T_max, t_0 × (Multiplier)^i). Highly vulnerable to wave-like server collisions.
  • Full Jitter (AWS Architecture Standard): Sleep_i = random_between(0, min(T_max, t_0 × (Multiplier)^i)). Optimal desynchronization with lowest mean server pressure.
  • Equal Jitter: half = min(T_max, t_0 × Multiplier^i) / 2; Sleep_i = half + random_between(0, half).
  • Cumulative Proxy Timeout Condition: Total retry duration must satisfy: Σ(Sleep_i + RequestLatency_i) < Proxy_Timeout to prevent HTTP 504 drops.

Standard Industry Retry Patterns

System Archetype Base (t₀) Max Retries Jitter Mode Cap (T_max) Typical Use Case
Internal Microservice RPC 50 - 100 ms 3 Full Jitter 2 seconds gRPC / Kubernetes service mesh
Public LLM / Cloud API 500 - 1000 ms 5 Full Jitter 30 seconds OpenAI, Claude, Stripe, AWS SDK
Asynchronous Webhooks 5.0 seconds 8 - 12 Equal Jitter 3600 seconds (1h) GitHub, Stripe, Shopify Webhook Delivery
Database Connection Pool 250 ms 6 Full Jitter 15 seconds PostgreSQL / Redis failover reconnect

Frequently Asked Questions (FAQ)

1. What is the thundering herd problem in API retries and why is jitter essential?
Without jitter, all failed clients retry at the exact same deterministic intervals. During outages, thousands of clients bombard the recovering server at identical timestamps in synchronized waves, knocking it down repeatedly. Jitter adds pseudo-random noise to spread retries evenly across time.
2. What is the difference between Full Jitter, Equal Jitter, and Decorrelated Jitter?
Full Jitter chooses sleep uniformly between 0 and the cap. Equal Jitter keeps 50% fixed and randomizes the remaining 50%. Decorrelated Jitter scales each step based on the prior sleep interval, providing the strongest desynchronization for congested backends.
3. How do retry policies cause 504 Gateway Timeout errors behind reverse proxies?
Proxies like Nginx, AWS ALB, or Cloudflare enforce strict timeout caps (typically 60s or 100s). If retries cumulative duration exceeds this budget, the proxy cuts the TCP socket and returns a 504 Gateway Timeout before the client completes its attempts.
4. Why must retried HTTP operations be strictly idempotent?
If a network timeout occurs after the server processed a request, reissuing a non-idempotent POST risks duplicate credit card charges or duplicated database rows. Use Idempotency-Key headers or restrict retries to safe/idempotent verbs (GET, PUT, DELETE).
Suscribirse Subscribe