Forty bookings a minute, thousands of looks
A co-working company rents meeting rooms in 30-minute slots across 30 sites. At the morning peak its booking service handles about forty bookings and cancellations a minute. In the same minute, every lobby screen redraws the day's rooms floor by floor, and members open the app's floor view to find a free room, several thousand reads in all. The two kinds of request want very different things from the same tables.
A booking touches a handful of rows and has rules to keep: the slot must be free, the member's plan must have hours left this month, and the party must fit in the room. It needs a transaction, and it is easiest to keep right in a small, normalised schema where each fact lives in one place. The floor view touches hundreds of rows and checks none of those rules: for every room and every slot of the day it wants the room's name, floor, capacity and equipment, and, if the slot is taken, who booked it and for which company. Against the booking tables that is a join of rooms, slots, bookings, members and companies, rerun on every redraw.
Serving both from one model means each side compromises the other. Each index added to the booking tables for the screens makes every booking write slower. Copy the company name onto each booking to save a join, and the booking code now has to rewrite old bookings when a company changes its name, a chore that has nothing to do with booking a room.
Two models, each with one job
CQRS, Command Query Responsibility Segregation, stops asking one model to do both jobs. Requests that change data and requests that read it go through separate models, which can share a database and a deployment or be built and scaled separately.
A request to change state is a command: BookRoom {room: atlas-3f, date: 2026-11-03, slot: 4, member: m-5530}. A command handler loads the part of the write model that the command affects, here the room's schedule for the day and the member's allowance, checks the rules and saves the change in one transaction. A unique constraint on room, date and slot backs it up, so two members who press Book on the same slot at the same moment cannot both succeed; the allowance needs a guard of its own, such as a conditional update of the hours left in that transaction. The handler answers with acceptance or rejection, and perhaps the new booking's id; it does not return pages of data.
A request that only asks is a query, and a query handler answers it from a read model: data stored in the shape one screen needs. Here that is a floor_view table with one row per room per slot, the member's and company's names already in place, so a lobby screen reads one site's rows for today by key and renders them. The read side checks no booking rules and never writes to the write model. A second screen with a different shape, say hours used per company for the monthly invoice, gets a second read model rather than a compromise with the first.
Getting the news across
The command handler could update floor_view in the same transaction as the booking, and the screens would never lag; but then every booking pays for every screen's table, and a new screen means changing the booking code. Most systems that adopt CQRS update the read models separately instead, so the write side has to say what changed. After a booking it emits an event, RoomBooked, and a projector on the read side applies each event to floor_view: fill the slot, write the member's and company's names. A cancellation clears it, and when a company changes its name the projector rewrites that company's rows: the chore from the start, moved to the read side. The diagram shows the path.
Bookings change the room schedules; screens read floor_view. The only way a change reaches the screens is the event path along the right.
Both ends of that path can break the read model for good. If the handler commits the booking and then publishes RoomBooked as a separate step, a crash between the two leaves the slot showing free until someone rebuilds the read model, which is why the event is saved with the booking and published by a relay, the Transactional Outbox in the diagram. That relay can deliver an event twice, so the inbox records each event's id in the same transaction as the update, as Idempotent Consumer describes, and events for one room must be applied in order; keeping and rebuilding a projected table belongs to Materialized View.
The room schedules stay ordinary rows here; making the events themselves the record is Event Sourcing, which pairs well with CQRS but is a separate decision.
Booked, and still showing free
An asynchronous read model trails the write model. Usually by a fraction of a second, but the gap is real: a member books Atlas for tomorrow's first slot, the app shows the confirmation, they go back to the floor view, and that slot is still free because the projector has not applied RoomBooked yet. Some will book again, and the write side will refuse the second booking, because the slot is now taken in the room schedules. The rules held. The member's trust did not.
This is a user not seeing their own write. What the member needs is read-your-writes, their reads reflecting their own booking, while everyone else's reads stay eventually consistent. The command can return the position of its event, and floor-view queries that carry that position wait, briefly, until the projector has applied it; if the wait runs out, the answer says the booking is still being applied instead of showing the old view as current. A lighter fix keeps the booking from the command's answer and draws it over the floor view until a response includes it, which protects only the app holding it. Consistency models: strong vs eventual (CAP) weighs the alternatives.
The reverse shortcut is the dangerous one. A command handler that checks availability by reading floor_view decides on data that can be behind: two members can each see Atlas free and both be told yes, unless the write side checks again. Commands decide against the write model, inside its transaction; the read model is for showing, never for permission.
A small lag is the price of updating the read model asynchronously. A lag nobody can see is the defect. If the projector stalls on a malformed event, floor_view freezes at that moment and every screen keeps showing rooms as free that were booked an hour ago, with no error anywhere. Record the position of the last event the projector applied, compare it with the last event the write side produced, and alert when the distance or the time between them grows.
A split worth its cost?
CQRS adds real complexity: two models to build and keep in step, a path between them that has to survive crashes and duplicates, and, when the read model is updated asynchronously, eventual consistency between them that every screen has to live with. The booking service earns that because its reads and writes differ in both volume and shape. Its site-settings pages, read and edited by a few administrators, do not, and a single model serves them better. Adopt CQRS where read and write loads or shapes genuinely diverge, and only for that part of the system. When the only problem is read volume on the same shape of data, Replication & read replicas is a smaller step.
Keep the two paths apart
The CQRS challenge asks for exactly this split. Draw the booking service with a Command handled by a Command Handler that updates the Write Model, a Query answered by a Query Handler from the Read Model, and a Domain Event carried by the Event Bus from one side to the other. The Challenge's palette has no Projector, so that last edge stands in for it. The Challenge asks for the event-driven form described above, so a good run reads as two separate paths, booking rules enforced only on the command side and screens served only from the read side, with events as the one link between them.