wtf( )unctionsystem design, drawn
← all problemsAPI DesignMedium

The retry that created three orders

A flaky connection means clients sometimes retry. Creating an order is a POST, and a retried POST creates a second order — correct behaviour for POST, and a terrible customer experience.

Setting a user's profile is also a POST here, and retrying that one is harmless. The two operations have genuinely different semantics and the API gives them the same method.

Assign each operation the method whose guarantees actually match it.
Components — tap one, then tap a slot on the diagram
!A retried create call produced three identical orders.

Outside every boundary: Create an order (each call is a new one), Read the profile (changes nothing), API (FAILED: duplicate orders), Set the profile (same result every time), an empty slot for the a retry duplicates, an empty slot for the a retry is harmless, an empty slot for the never changes state Connections: Create an order calls a retry duplicates (step 1) Set the profile calls a retry is harmless (step 2) Read the profile calls never changes state (step 3) a retry is harmless calls API

Create an ordereach call is a new one
Read the profilechanges nothing
APIduplicate orders
Set the profilesame result every time