wtf( )unctionsystem design, drawn
← all problemsResilienceEasy

The inner timeout outlived the outer one

The gateway times out at five seconds. The service it calls times out at thirty. The database call behind that has no timeout at all.

When the database is slow the gateway returns an error at five seconds, and the service carries on for another twenty-five — holding a thread, a connection and a database session — for a client that has already been told no.

Order the timeouts so each layer gives up before the layer waiting on it.
Components — tap one, then tap a slot on the diagram
!The gateway gave up after 5 seconds. The service behind it kept working for 30, on a request nobody was waiting for.

Outside every boundary: Service (FAILED: still going at 30s), Gateway (gives up at 5s), Client (waits 6 seconds), Database (no timeout at all; FAILED: unbounded), an empty slot for the shorter than the gateway, an empty slot for the shorter again, and present Connections: Client calls Gateway (step 1) Gateway calls Service (step 2) Service calls Database (step 3) shorter than the gateway controls Service shorter again, and present controls Database

Servicestill going at 30s
Gatewaygives up at 5s
Clientwaits 6 seconds
Databaseno timeout at allunbounded