0
0
LLDsystem_design~10 mins

Hotel, Room, Booking classes in LLD - Scalability & System Analysis

Choose your learning style9 modes available
Scalability Analysis - Hotel, Room, Booking classes
Growth Table: Hotel Booking System
ScaleUsersRoomsBookings per daySystem Changes
Small100500200Single server, simple database, no caching
Medium10,00050,00010,000Load balancer, read replicas, caching for availability checks
Large1,000,000500,000100,000Sharded database, distributed cache, asynchronous booking processing
Very Large100,000,00010,000,00010,000,000Multi-region deployment, event-driven architecture, CDN for static content
First Bottleneck

At small to medium scale, the database is the first bottleneck. It handles all booking transactions and availability checks. As users and bookings grow, the database CPU and I/O get overwhelmed, causing slow responses and possible booking conflicts.

Scaling Solutions
  • Database Read Replicas: Offload read queries like room availability checks to replicas to reduce load on the primary database.
  • Caching: Use in-memory caches (e.g., Redis) for frequently accessed data like room availability to reduce database hits.
  • Horizontal Scaling: Add more application servers behind a load balancer to handle increased user requests.
  • Database Sharding: Split booking data by hotel or region to distribute load across multiple database instances.
  • Asynchronous Processing: Use message queues to handle booking confirmation and payment processing asynchronously to improve responsiveness.
  • Multi-region Deployment: Deploy services closer to users to reduce latency and improve availability.
Back-of-Envelope Cost Analysis
  • At 10,000 bookings/day (~0.12 QPS), a single database can handle the load easily.
  • At 100,000 bookings/day (~1.2 QPS), database load increases; read replicas and caching become necessary.
  • Storage: Each booking record ~1 KB, so 10 million bookings need ~10 GB storage, manageable with modern databases.
  • Network bandwidth: Assuming 1 KB per booking request/response, 100,000 bookings/day require ~100 MB data transfer, well within 1 Gbps network capacity.
Interview Tip

Start by describing the system components and their roles (Hotel, Room, Booking). Then discuss expected traffic and data growth. Identify the first bottleneck (usually the database). Propose scaling solutions step-by-step, explaining why each is needed. Use real numbers to justify your choices. Finally, mention trade-offs and monitoring strategies.

Self Check

Your database handles 1000 QPS. Traffic grows 10x to 10,000 QPS. What do you do first?

Answer: Add read replicas to distribute read queries and reduce load on the primary database. Also, implement caching for frequent read operations like room availability checks. This reduces database CPU and I/O usage, preventing overload.

Key Result
The database is the first bottleneck as bookings grow; scaling requires read replicas, caching, and sharding to maintain performance.