🏨

Designing a Hotel Booking System

Oct 9, 2024

Hotel Booking System Design

Introduction

  • Presenter: Sandeep from CodeKarle
  • Topic: High-level architecture of a hotel booking system, similar to Booking.com or Airbnb.

Functional Requirements

Hotel Manager Functionality

  1. Onboarding onto the platform.
  2. Updating property information (e.g., adding rooms, changing pricing, uploading images).
  3. Viewing bookings and revenue insights.

User Functionality

  1. Searching for properties in specific locations with filters (e.g., price range, property type).
  2. Booking hotels.
  3. Viewing existing bookings.

Analytics

  • Design should allow for analytics capabilities.

Non-Functional Requirements

  • Low latency.
  • High availability.
  • High consistency: Immediate visibility of booking status.

Scale Considerations

  • 500,000 hotels globally, ~10-12 million rooms.
  • Hotels can have many rooms; most will not face simultaneous booking of all rooms.

System Design Overview

Components

  1. UI for Hotel Managers: Website/mobile app for onboarding and property management.
  2. Load Balancer: Distributes traffic to hotel service.
  3. Hotel Service: Manages hotel data (CRUD operations).
  4. Database: Uses clustered MySQL with one master and multiple slaves for scalability.
  5. CDN: Stores hotel images, with URLs referenced in the database.
  6. Kafka: Handles event streaming for updates in hotel data.
  7. Search Service: Uses Elasticsearch for fuzzy searching and filtering.
  8. Booking Service: Processes bookings and interacts with the Payment Service.
  9. Notification Service: Sends notifications for bookings and changes.
  10. Booking Management Service: Allows users to view their bookings, interacting with MySQL and Cassandra.
  11. Analytics: Uses Hadoop for event log analysis.

Data Flow

  • Hotel Changes: Changes flow through Kafka to update search databases.
  • Search: User queries are handled by Search Service with Elasticsearch.
  • Booking Process: Requests flow through Booking Service, interacting with MySQL and Payment Service. Bookings update available room statuses via Kafka.
  • Archival: Completed or canceled bookings stored in Cassandra.

Caching

  • Redis cache on booking data to reduce load on MySQL.

Detailed Component Overview

Hotel Service

  • CRUD functionality for hotel data.
  • APIs include POST (create hotel), GET (retrieve hotel info), PUT (update hotel info).
  • Database schema includes hotel details, room details, facilities, etc.

Booking Service

  • Handles bookings through MySQL.
  • Tracks available rooms and booking statuses (reserved, booked, canceled, completed).
  • Implements payment handling with timeout for payment processing using Redis TTL.

API Signatures

  • Book API for creating bookings, checking availability, and managing statuses.

Alternative Approaches

  • Use of different databases (Postgres, SQL Server) for relational data.
  • Caching alternatives (Memcache).
  • Event streaming alternatives (Active MQ, Rabbit MQ).

Monitoring and Alerts

  • Monitor CPU, memory, and disk usage across services.
  • Use tools like Grafana for setting up alerts.

Geographic Distribution

  • Proposed a multi-data center approach for improved latency and availability.
  • Data centers can be split by region, allowing users to connect to the nearest server.

Conclusion

  • Overall design aims to meet both functional and non-functional requirements while ensuring scalability, availability, and ease of maintenance.