System Design

Preventing Double Bookings with Optimistic Locking

System Design diagram · made in Skemio

Architecture diagram of a hotel booking flow using Redis for hold timers and PostgreSQL optimistic locking with version checks.
Architecture diagram of a hotel booking flow using Redis for hold timers and PostgreSQL optimistic locking with version checks.

What it shows

  • Room hold timers expire in Redis after 10-15 mins to release inventory.
  • Version checks (`WHERE version = v`) reject stale updates concurrently.
  • Avoids heavy pessimistic table locks that degrade DB read throughput.

The takeaway

Optimistic locking with TTL holds keeps inventory accurate without locking entire database tables.

More system design diagrams