System Design Atlas

Hotel inventory and room pricing

07 / 10Worked example

Critical flow

What reservation evidence survives a lost response, and which actions are then permitted?

Now the architecture is tested at its sensitive point of failure. Reservation API locks category nights in date order, checks the remaining inventory for both nights and commits the reservation together with the channel request. After a lost response, the same key delivers the same reservation. External channel success is reconciled separately.

Starting point Room-night inventory remains with the reservation core.

Assumptions for the example case

Own fictitious example design. One hotel, one room category, full nights and a fixed offer in EUR without prepayment. A price offer is valid for 300 seconds; at exactly 300 seconds, a new confirmation is rejected. All figures and test goals are illustrative assumptions.

Critical flow with commit and failure point

Critical flow · Commit, failure point and replay

The Reservation API locks both category nights in date order and stores Reservation plus channel order together.

Guest interface
Reservation API
Category-night inventory
Channel reconciliation
Distribution channel
  1. 01 Guest interface → Reservation APIConfirm A-27 for two nights
  2. 02 Reservation API → Category-night inventoryLock both nights in date order
  3. 03 Reservation API → Category-night inventoryCheck remaining inventory; commit R-27 + channel request
  4. 04 Category-night inventory → Reservation APICommit is durable
  5. 05 Reservation API · Local processingThe response to the guest interface is lost
  6. 06 Guest interface → Reservation APIRepeat the same confirmation command
  7. 07 Reservation API → Guest interfaceDeliver stored R-27
  8. 08 Channel reconciliation → Category-night inventoryLoad the committed channel request
  9. 09 Channel reconciliation → Distribution channelConfirm R-27
  10. 10 Distribution channel → Channel reconciliationAcknowledge the channel reference

Result: Both nights are committed together; replay and channel reconciliation provide evidence for the same reservation.

A reservation atomically occupies all required nights without exceeding inventory.

Reservation API locks category nights in date order, checks the remaining inventory for both nights and commits the reservation together with the channel request. After a lost response, the same key will deliver the same reservation. External channel success is reconciled separately.

Ordering and failure outcomes

Required order
Reservation API locks category nights in date order, checks the remaining inventory for both nights and commits the reservation together with the channel request. After a lost response, the same key will deliver the same reservation. External channel success is reconciled separately.
Crash before commit
For reservation R-27 there is no new permanent proof. The same command may be re-examined; unconfirmed intermediate work does not give a business guarantee.
Crash after commit, before response
The command journal entry records the original result. Identical replay returns that evidence; a fresh view of the current state comes from the read contract.
External uncertainty
A lack of feedback from the distribution channel remains unknown. Confirmed acceptance, definite rejection and lack of proof are given distinct states; the responsible role clarifies using the same reference.

Channel reconciliation follows the local commit

Channel reconciliation follows the local commit

Channel reconciliation follows the local commit.

Reservation API locks category nights in date order, checks the remaining inventory for both nights and commits the reservation together with the channel request. After a lost response, the same key will deliver the same reservation. External channel success is reconciled separately.

Each confirmed reservation atomically occupies all required nights; occupancy never exceeds the local inventory for its room category. The exercise specifies the input and expected result.

Alternative considered
Submitting a new request after a response is lost can execute the same business operation again.
Trade-off
Unresolved evidence from the distribution channel requires a work queue.
Reassess
Frequent unresolved outcomes require a more reliable contract for external reconciliation.

Try it yourself

Mark the commit point, failure point and next permitted action. Explain the effect of an identical retry.

A hint for your attempt

Trace the same request through the datastore and response path.

Compare with a possible solution
Flow and failure
Reservation API locks category nights in date order, checks the remaining inventory for both nights and commits the reservation together with the channel request. After a lost response, the same key will deliver the same reservation. External channel success is reconciled separately.
Commit and replay
The domain change and command result are stored together before response. Loss of response after commit leads to reading this result. For reservation R-27, this does not have a second effect.

Apply to your project

What feedback could be missing even though the underlying action has already taken place?

Next: Search results may be older than the data used to decide a booking.