System Design
  • Introduction
  • Glossary of System Design
    • System Design Basics
    • Key Characteristics of Distributed Systems
    • Scalability - Harvard lecture
      • Scalability for Dummies - Part 1: Clones
      • Scalability for Dummies - Part 2: Database
      • Scalability for Dummies - Part 3: Cache
      • Scalability for Dummies - Part 4: Asynchronism
    • Trade-off
      • CAP Theorem
      • Performance vs scalability
      • Latency vs throughput
      • Availability vs consistency
    • Load Balancing
      • Load balancer
    • Proxies
      • Reverse proxy
    • Cache
      • Caching
    • Asynchronism
    • Processing guarantee in Kafka
    • Database
      • Relational database management system (RDBMS)
      • Redundancy and Replication
      • Data Partitioning
      • Indexes
      • NoSQL
      • SQL vs. NoSQL
      • Consistent Hashing
    • Application layer
    • DNS
    • CDN
    • Communication
      • Long-Polling vs WebSockets vs Server-Sent Events
    • Security
    • Lambda Architecture
  • OOD design
    • Concepts
      • Object-Oriented Basics
      • OO Analysis and Design
      • What is UML?
      • Use Case Diagrams
    • Design a parking lot
  • System Design Cases
    • Overview
    • Design a system that scales to millions of users on AWS
    • Designing a URL Shortening service like TinyURL
      • Design Unique ID Generator
      • Designing Pastebin
      • Design Pastebin.com (or Bit.ly)
    • Design notification system (scott)
      • Designing notification service
    • Designing Chat System
      • Designing Slack
      • Designing Facebook Messenger
    • Design Top K System
    • Designing Instagram
    • Design a newsfeed system
      • Designing Facebook’s Newsfeed
      • Design the data structures for a social network
    • Designing Twitter
      • Design the Twitter timeline and search
      • Designing Twitter Search
    • Design Youtube - Scott
      • Design live commenting
      • Designing Youtube or Netflix
    • Designing a Web Crawler
      • Designing a distributed job scheduler
      • Designing a Web Crawler/Archive (scott)
      • Design a web crawler
    • Designing Dropbox
    • Design Google Doc
    • Design Metrics Aggregation System
      • Design Ads Logging System
    • Design Instacart
    • Design a payment system
      • Airbnb - Avoiding Double Payments in a Distributed Payments System
    • Design Distributed Message Queue
      • Cherami: Uber Engineering’s Durable and Scalable Task Queue in Go
    • Design Distributed Cache
      • Design a key-value cache to save the results of the most recent web server queries
    • Design a scalable file distribution system
    • Design Amazon's sales ranking by category feature
    • Design Mint.com
    • Design Autocomplete System
      • Designing Typeahead Suggestion
    • Designing an API Rate Limiter
      • Designing Rate Limiter
    • Design Google Map
      • Designing Yelp or Nearby Friends
      • Designing Uber backend
    • Designing Ticketmaster
      • Design 12306 - Scott
    • Design AirBnB or a Hotel Booking System
  • Paper Reading
    • MapReduce
  • Other Questions
    • What happened after you input the url in the browser?
Powered by GitBook
On this page
  • Design AirBnB or a Hotel Booking System
  • Requirements
  • Guests
  • Hotel or Rental Admin
  • High-level architecture
  • Detailed Design
  • Data Structure for User, Room and Booking
  • How to find available rooms?
  • External Hotel Supplier
  • Payment
  • Notification

Was this helpful?

  1. System Design Cases

Design AirBnB or a Hotel Booking System

Design AirBnB or a Hotel Booking System

Requirements

Guests

  • search rooms by locations, dates, and number of guests

  • get room details(like picture, name, review, address, etc) and prices

  • pay and book room from inventory by date and by room_id

    • checkout as a guest

    • user is logged in already

  • notification via Email and mobile push notification

Hotel or Rental Admin

  • manage room inventory and help the guest to check-in and check out

  • housekeeper: clean up rooms routinely


High-level architecture


Detailed Design

Data Structure for User, Room and Booking

  • The basic tables are: reservation, guest and room.

  • use status to represent the status of a room: EMPTY, RESERVED


How to find available rooms?

Method 1: By location

    • e.g. geo-hash or quad-tree

Method 2: By room metadata

  • apply filters or search conditions when query the database

Method 3: By data-in and data-out availability

  • option 1(recommended): for each room_id, create an entry for an occupied day. It will be easier to query unavailable slots by dates

  • option 2: for each room_id, check all occupied_room from today.

    • transform the data structure to an array of occupied days

    • keep searching until got the available slots

    • this is time-consuming, so we can build the availability index


External Hotel Supplier

  • provide webhook callback APIs to external vendors to update status in the internal system


Payment

Bookkeeping

  • sync data across transaction table and external banks and vendors


Notification

The notification system is essentially a delayer scheduler (priority queue + subscriber) plus API integrations.

  • For example, a daily cronjob will query the database for notifications to be sent out today and put them into the priority queue by date.

  • The subscriber will get the earliest ones from the priority queue and send out if reaching the expected timestamp.

  • Otherwise, put the task back to the queue and sleep to make the CPU idle for other work, which can be interrupted if there are new alerts added for today.

PreviousDesign 12306 - ScottNextPaper Reading

Last updated 3 years ago

Was this helpful?

Ref:

geo-search with

Ref:

retry with to improve the success rate of the external calls and ensure no duplicate orders

data model:

Designing a Data Model for a Hotel Room Booking System
spatial indexing
Stripe Idempotency
idempotency
double-entry bookkeeping