Synchronous vs Asynchronous API Design
Design long-running HTTP interfaces: 202 Accepted, polling status endpoints (/jobs/123), webhook callbacks, and streaming progress.
01.1. The Synchronous HTTP Timeout Hazard
In distributed systems, operations that take more than 2 to 3 seconds (e.g., video transcoding, PDF invoice generation, machine learning inference, bulk database exports) must never be handled synchronously over a single blocking HTTP request.
Why Long Synchronous Calls Cause Catastrophic Outages:
- Load Balancer & Gateway Timeouts: Intermediate reverse proxies (AWS ALB, Cloudflare, NGINX) enforce strict timeout limits (typically 30 to 60 seconds). If the backend takes 61 seconds, the gateway terminates the connection with
504 Gateway Timeout, even if the backend continues consuming CPU. - Thread & Socket Pool Starvation: Synchronous web servers (Gunicorn, Puma, Tomcat) allocate a worker thread or socket per incoming connection. A surge of 500 concurrent long-running requests blocks all 500 worker threads, causing total system unavailability for fast, lightweight CRUD requests.
- Ghost Computations: If a mobile client loses cellular connection during a 2-minute synchronous request, the client disconnects, but the backend server blindly completes the expensive computation with no client to receive the result.
Asynchronous Long-Running Task Lifecycle (HTTP 202 Accepted) ā³
Asynchronous Long-Running Task Lifecycle (HTTP 202 Accepted) ā³
Decoupling heavy background processing from HTTP request/response lifecycles.
Unlock Topic #133: Synchronous vs Asynchronous API Design
You are viewing a preview. The full in-depth engineering deep dive, interactive simulators, architecture flowcharts, and self-assessment quizzes for this topic are available with Pro or Lifetime Access.
Failure modes, high-throughput bottlenecks, and real FAANG implementation decisions.
Interactive system topology diagrams, live parameter simulators, and downloadable SVG charts.
Staff-level multiple-choice quiz questions with instant feedback and answer explanations.
Firebase Google authentication automatically syncs your completed topics and quiz scores.
How clear and staff-actionable was this system breakdown?