BOOKMYSHOW System Design, FANDANGO System Design | Software architecture for online ticket booking
System Design for a Movie Ticket Booking Platform
Introduction to System Design
- Lorraine introduces the session focused on designing a scalable movie ticket booking platform, similar to BookMyShow or Fandango.
- Emphasizes the complexity of creating a highly available and fault-tolerant system that requires continuous optimization over time.
Overview of Ticket Booking Process
- Describes the basic operation where users request tickets through an aggregator (BMS), which then communicates with theaters to secure bookings.
- Highlights user experience by allowing visibility into available and booked seats in real-time.
Strategies for Seat Availability
- Discusses two strategies for checking seat availability:
- Directly connecting to theater databases for immediate access to seat data.
- Utilizing theater APIs that provide endpoints for fetching available/unavailable seats and booking functionalities.
Locking Mechanism in Booking
- Explains the necessity of a locking mechanism when multiple users attempt to book the same seat simultaneously.
- Details how the server should manage reservations, holding a seat for 10 minutes before releasing it if not booked.
Performance Considerations
- Notes that using APIs can lead to increased network I/O calls, suggesting programming languages like Python, Erlang, or Go for efficient handling of requests.
Features Required in the System
- Stresses the importance of defining features before system design; encourages clarification with stakeholders about expected functionalities.
Key Features Identified
- High Concurrency:
- BMS handles approximately 90,000 tickets daily; thus, it must support high concurrency due to numerous simultaneous requests.
- Responsive UI:
- The platform should be accessible across various devices (mobile apps, tablets, desktops), enhancing user experience through responsive design.
- Geographical Scalability:
- The system must accommodate operations across different cities and countries while maintaining performance standards.
- Digital Payment Support:
- Integration with various payment methods including credit/debit cards and digital wallets is essential.
- Recommendation System:
- Implementing algorithms that suggest movies based on user preferences enhances engagement and personalization.
- User Interaction Features:
- Comments and ratings functionality allows users to share their experiences after watching movies.
- Media Content Display:
- Users should have access to trailers, cast information, pictures, etc., enriching their interaction with movie profiles.
- Ticket Confirmation Delivery:
- Sending ticket confirmations via SMS or email ensures users receive necessary information post-booking ((#)).
Conclusion of Feature Discussion
Load Balancing and Application Architecture
Load Balancing Techniques
- The discussion begins with the importance of load balancing in a highly concurrent system, especially when scaling application servers horizontally.
- Various techniques for load balancing are introduced: consistent hashing, round-robin, weighted round robin, and least connection strategies.
Front-End Caching
- Varnish is highlighted as a front-end caching system that enhances user experience (UX) and reduces pressure on back-end infrastructure.
- Content Delivery Networks (CDNs) can also be utilized to cache pages, APIs, videos, or images.
Application Servers
- Multiple app servers are necessary to handle heavy loads; Java Spring, Swagger, and Hibernate are mentioned as technologies used by Book My Show.
- Alternatives like Python-based servers or Node.js can also be considered based on specific requirements.
Data Management Strategies
Utilizing Elasticsearch
- Elasticsearch is recommended for handling search queries efficiently due to its distributed nature and full-text search capabilities.
Importance of Caching
- Caching is crucial for storing information related to movies and seat ordering. Memcached and Redis are discussed as options for caching solutions.
Database Choices
- A combination of RDBMS (Relational Database Management System) and NoSQL databases is suggested for optimal data management.
RDBMS Considerations
- RDBMS is essential for maintaining ACID properties and managing relationships between entities such as countries, cities, theaters, screens, rows of seats, etc.
NoSQL Applications
- For large datasets like movie-related information (comments/reviews), NoSQL databases like Cassandra are suitable due to their ability to handle big data effectively.
Scalability Solutions
Master-Slave Architecture
- Implementing a master-slave architecture allows read operations on slave nodes while write operations occur on the master node to enhance scalability.
Data Replication Benefits
- NoSQL databases offer geo-distributed data storage with adjustable replication factors ensuring high availability and durability even during node failures.
Asynchronous Processing
Need for Asynchronous Workers
- Asynchronous workers are necessary for tasks that involve third-party API calls (e.g., sending emails/SMS after ticket booking), which could introduce latency if handled synchronously.
Task Queue Implementation
- Upon confirming a ticket booking request, messages indicating the need for further processing (like generating PDFs or sending notifications via WhatsApp/SMS/email) are added to a queue.
Worker Framework Options
Business Intelligence and User Interaction in Ticket Booking Systems
Data Processing and Analysis
- The system utilizes Hadoop HDFS to store user activity logs, enabling the extraction of insights related to user behavior through high queries.
- Kafka is employed as a queue to facilitate real-time data processing with Spark or Storm, allowing for trend analysis and monitoring of user activities.
- The system can also implement fraud detection strategies using stream processing engines like Spark and Storm.
Payment Gateway Integration
- A third-party payment gateway (e.g., JustPay) is integrated to handle various payment methods including credit cards and digital wallets during ticket booking.
- Upon receiving a ticket request, the system communicates with the payment gateway for transaction confirmation before issuing tickets.
User Journey in Ticket Booking
- Users begin by filtering locations via GPS on mobile devices or IP-based location on laptops to find nearby theaters showing selected movies.
- Once a movie is chosen, users can view available showtimes and seat availability; seats are temporarily locked for 10 minutes while the user completes their booking.
Ticket Confirmation Process
- After selecting seats, users proceed to checkout where they confirm payment through the gateway; successful transactions trigger ticket generation with unique IDs.
- Tickets are sent via email/SMS containing QR codes that users present at theaters for entry verification against theater records.
System Architecture Overview
- The entire BMS operates on an Amazon platform utilizing microservices architecture, ensuring independent operation of components without monolithic constraints.
- Various technologies are used: React.js for UI development, Spring Boot for server-side logic, MySQL as the database, and Hazelcast for caching solutions.
Logging and Monitoring Mechanisms
- Logs from different services are collected using Logstash; these logs undergo filtering before being redirected to ELK stack for monitoring purposes.
- Dashboards can be created in Kibana to visualize error rates and other metrics based on log data processed through this pipeline.
Database Design Considerations
System Design for Ticket Booking Platform
Overview of Seat Tiers and Pricing
- The system will feature multiple tiers of seats, each with different pricing structures. This allows for varied pricing based on the tier and row of seats.
- Only one movie can be played in a particular screen at any given time, establishing a one-to-one relationship between screens and movies.
Database Structure Requirements
- A primary table is needed to store various offers available for specific movies, screens, or seats.
- A user table must be created to hold user information, allowing users to book multiple tickets that can include several seats.
NoSQL Database Considerations
- The database design must anticipate all potential queries since NoSQL databases do not support traditional relationships or joins between tables.
- Essential tables include those for comments, ratings, movie descriptions, video/audio paths, artist information, cast and crew details, reviews, and analytics data.
System Design Complexity