Designing Data-Intensive Applications
Case 4

Requirements and Constraints

Hotels, flights, restaurants, and concerts sell finite inventory that must never be oversold.

Reservation systems are classic OLTP with brutal correctness requirements. A double-booked hotel room destroys trust faster than a slow search page.

Airbnb at scale

Guests search Elasticsearch-backed listings but commit bookings through a transactional core that decrements night-level inventory in PostgreSQL with row-level locks or serializable isolation.

Why these technologies?

Why Elasticsearch / OpenSearch?

Guests search by date range, location, price, amenities — fuzzy, faceted queries that SQL can do but not at Airbnb-scale relevance ranking. Index is rebuilt from listing events; stale by seconds is OK.

Why PostgreSQL (inventory OLTP)?

A night sold twice destroys trust — needs ACID, row locks, unique constraints, and serializable transactions on inventory rows. DynamoDB can work with careful conditional writes but SQL is the default for booking invariants.

Why API gateway?

Routes read-heavy search traffic separately from write-heavy booking commits. Can throttle abusive search without starving checkout.

Why Stripe / Adyen (payments)?

PCI-DSS compliance, card vaulting, and dispute handling outsourced — building this in-house is a non-starter for most products.

Why Kafka?

After booking commits, emails, search index updates, analytics, and host notifications run async. Outbox pattern ensures events publish only after DB commit.

Why Redis (optional hold TTL)?

Fast expiry of abandoned cart holds with key TTL + background sweeper. Source of truth remains Postgres; Redis accelerates 'is this hold still valid?' checks.

Why Saga / workflow orchestrator?

Hold → pay → confirm spans services — no single XA transaction across Stripe and your DB. Compensating release on payment failure is mandatory.

Key Takeaways
  • Search is read-heavy and fuzzy; booking is write-heavy and exact.
  • Holds: temporary locks while user pays (10–15 minute TTL).
  • Payments tie to reservations — sagas coordinate both.
  • Cancellations and modifications release inventory back to the pool.
  • Calendar queries need efficient range indexes on availability.
  • Time zones and daylight saving complicate 'night' inventory.
bookinginventoryOLTPsearchholdsElasticsearchStripe