wtf( )unctionsystem design, drawn
← all problemsDistributed SystemsHard

Reads and writes that want opposite things

The write side needs normalised tables and transactions. The dashboard needs one wide row per customer, and building it joins nine tables on every page load.

Splitting the models is the answer, but the two stores now have to be kept in step — and the thing that does that is where the whole design lives or dies.

Place what carries changes from the write model to the read model.
Components — tap one, then tap a slot on the diagram
!The dashboard joins nine tables on every page load and times out for the largest customers.

Boundaries, outermost first: Write side: Write store (normalised), Command handler (validates) Read side: Read store (one row per view; FAILED: too slow), Query handler (no joins) Outside every boundary: an empty slot for the keeps them in step Connections: Command handler calls Write store — persist (step 1) Write store publishes to keeps them in step — change events (step 2) keeps them in step publishes to Read store — upsert view (step 3) Query handler calls Read store — single read

Read storeone row per viewtoo slow
Write storenormalised
Query handlerno joins
Command handlervalidates