Recently I interviewed a Senior Engineer.
Strong candidate.
Kafka? β
Redis? β
Microservices? β
Distributed systems? β
Then I asked:
"You're building the seat booking system for a sold-out concert.
10,000 seats.
A user picks seat A12 and hits Book.
Two users hit Book on the exact same seat at the same millisecond.
Both see it as available.
Both create a reservation.
Both get a success response.
Now two people think they own the same seat.
How do you guarantee a seat is never double-booked β even with concurrent requests, client retries, and partial failures?"
"Just use a database transaction."
Doesnβt fully solve it if both requests read `available = true` before either writes, or if the response is lost and the client retries.
"Check availability then update."
What happens when both checks happen at the same time?
"Use Redis SETNX and reject if the key already exists."
What happens if Redis is down, the lock expires, or the booking is never persisted?
Your turn:
How would you design this seat reservation API so concurrent buyers and retries never double-book the last seat?
Thereβs a specific distributed-systems concept behind this.
And youβll encounter it everywhere limited resources are involved β seats, tickets, rooms, appointments, inventory.