wtf( )unctionsystem design, drawn
← all problemsAPI DesignEasy

The request that runs for four minutes

Generating a report takes minutes. The endpoint holds the connection open until it's finished, and clients time out long before that — then retry, starting a second report.

The work is legitimate. Holding an HTTP request open while it happens is what's wrong: every proxy, load balancer and client on the path has its own idea of how long is too long.

Answer immediately, and give the client a way to find out when it's done.
Components — tap one, then tap a slot on the diagram
!Report requests time out and every retry starts another report.

Outside every boundary: Worker (takes minutes), Client (times out at 60s; FAILED: timing out), an empty slot for the the immediate response, an empty slot for the where the client looks Connections: Client calls the immediate response — start it (step 1) the immediate response publishes to Worker (step 2) Client calls where the client looks — is it done? (step 3) Worker publishes to where the client looks — result (step 4)

Workertakes minutes
Clienttimes out at 60stiming out