Design BookMyShow
Difficulty: MEDIUMCategory: HLDFrequency: 1Asked On 2022-04-03
Problem Statement
Design a scalable, fault-tolerant, and high-performance ticket booking system like BookMyShow, where users can browse movies/events, check showtimes, select seats, and book tickets in real time while ensuring seat availability consistency and high concurrency handling.
Functional Requirements
1.User Management
•User registration, authentication, and profile management.
•Support multiple devices.
2.Movie/Event Browsing
•Search by city, theater, language, date, and genre.
•View showtimes, available seats, pricing.
3.Seat Selection & Booking
•Real-time seat availability check.
•Locking mechanism during seat selection.
•Ticket booking confirmation & digital ticket generation.
4.Payments
•Multiple payment options (UPI, Cards, Wallets).
•Payment gateway integration.
•Retry/cancellation support.
5.Notifications
•SMS/Email/Push notifications for booking confirmation & reminders.
6.Admin Features
•Theater onboarding & show scheduling.
•Pricing configuration (weekend, peak hours, offers).
Non-Functional Requirements
•Scalability → Handle millions of concurrent seat bookings during peak events.
•Consistency → Prevent double booking of the same seat.
•Low Latency → Real-time seat availability update (<100ms).
•Reliability → Ensure bookings persist even on server failures.
•High Availability → 99.99% uptime SLA.
•Security → Secure payments, fraud detection, encryption.
Design Considerations
•Seat Availability & Locking
•Implement distributed locks (e.g., Redis/ZooKeeper) for real-time seat reservations.
•Seat held for short lock period (2–5 mins) before auto-release if payment fails.
•Data Storage
•RDBMS (MySQL/Postgres) for transaction integrity (bookings, payments).
•NoSQL (Cassandra/MongoDB) for fast reads (movie listings, showtimes).
•Redis cache for real-time seat availability.
•Services & APIs
•searchMovies(city, date)
•getShowDetails(showId)
•lockSeats(showId, seatIds, userId)
•confirmBooking(bookingId, paymentInfo)
•releaseSeats(bookingId)
•Scalability
•Sharding by city/theater for DB scalability.
•CDN for static content (posters, trailers).
•Queue-based async processing for notifications & retries.
•High Availability
•Deploy across multiple regions with geo-replication.
•Use load balancers + stateless services.
•Payments & Reliability
•Payment service with retry, idempotency keys.
•Compensation service for failed transactions.