wtf( )unctionsystem design, drawn
← all problemsCachingMedium

The two writes that must happen in this order

Read traffic is hammering the database, so the team is adding a cache. On a miss, the app reads from the database and stores the result. That part everyone gets right.

The write path is where this goes wrong, and it goes wrong quietly — the data is correct in the database and stale in the cache, forever, until something evicts it.

Order the write path: place the two steps in the boxes numbered 1 and 2.
Components — tap one, then tap a slot on the diagram
!A price was updated an hour ago. Customers are still being shown the old one.

Boundaries, outermost first: Data tier: Database (source of truth), Cache (key → value; FAILED: stale forever) Application: App server (owns the logic) Outside every boundary: an empty slot for the step 1, an empty slot for the step 2 Connections: App server calls step 1 (step 1) step 1 calls Database App server calls step 2 (step 2) step 2 calls Cache

Databasesource of truth
Cachekey → valuestale forever
App serverowns the logic