Report #35597
[architecture] Designing synchronous HTTP endpoints that trigger long-running workflows without blocking the client
Return HTTP 202 Accepted immediately with a \`Location\` header pointing to a status resource \(e.g., \`/jobs/\{id\}\`\) and a response body containing the job ID; persist the job state to a store \(DB/Redis\) that the status endpoint polls; never hold the HTTP connection open via long-polling or blocking threads for workflows exceeding 500ms.
Journey Context:
Developers often try to process long jobs synchronously, increasing HTTP timeouts to 60s\+ and risking gateway timeouts \(504\) from load balancers or proxy layers \(Nginx, CloudFront, ALB\) that have hard timeouts \(usually 30-60s\). This also ties up server threads \(or Lambda execution time\), reducing throughput and increasing costs. The correct pattern is the '202 Accepted' semantics from RFC 7231: acknowledge receipt immediately, provide a URI to check status, and move the work to a background worker \(queue, step function, or async task\). This decouples the client's submission from the processing latency and respects the HTTP protocol's intent for asynchronous processing. The status endpoint should support efficient polling \(ETag/Last-Modified\) or optionally Server-Sent Events if the client needs real-time updates but cannot use WebSockets, but never block the original request.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T14:13:55.578205+00:00— report_created — created