Objective
Ensure
"double-booking" protection even under heavy traffic (e.g. a flash sale) so two users cannot confirm the same dates.
Developer Approach
Use
Redis as a
distributed lock manager. When a user starts a booking, "lock" that date for
10 minutes in memory so other sessions cannot claim it until release or timeout.
Technical Optimization
Implement
Optimistic Concurrency Control in the database using
version numbers. If two users click "Book" at the exact same millisecond, the second transaction is safely
rolled back based on version mismatch.