Article
Shipping a booking engine without losing a night of sleep
What actually keeps a real-time booking engine stable in production: idempotent writes, explicit failure paths, and a checkout you can reason about.
A booking engine looks simple from the outside: pick a date, pay, get a confirmation. Underneath, it is one of the least forgiving systems you can build. Money moves, inventory is finite, and users retry when they are anxious.
Make writes idempotent
The single most valuable habit is treating every booking write as something that might arrive twice. Assign an idempotency key the moment a checkout begins, and let the database — not the application — enforce that a key can only produce one reservation.
- The user double-clicks "Pay" — you charge once.
- The payment gateway retries a webhook — you record it once.
- A mobile connection drops mid-request — the retry is safe.
Give every failure a path
Availability checks fail. Gateways time out. The question is never if but what happens next. Every failure in the checkout flow should resolve to a state the user and the operator can both understand:
- Pending — we are waiting on the gateway.
- Confirmed — money captured, inventory held.
- Released — the hold expired and stock returned to the pool.
Keep the checkout boring
Boring is a feature. A checkout you can read top to bottom, with explicit states and no clever shortcuts, is one you can debug at 2am. That is worth more than any micro-optimisation.
The engine that ships and stays up is almost always the one that made fewer clever choices, not more.