System Design LabSystem Design QuestionsDesign Airbnb

Design Airbnb

MediumE-commercebookingsearchgeolocationconcurrencypayments

Question Overview

Design a home-rental marketplace where guests search by map and dates and book stays from hosts. The interesting problems are searching millions of listings by location and multi-night availability at once, and guaranteeing no night is ever double-booked, including the request-to-book flow with payment holds.…

Sign up to see the full question and AI interviewer

Requirements

  • Hosts create listings with photos, prices, and a per-night availability calendar
  • Guests search by map area, dates, guest count, and price, seeing only listings free for every requested night
  • Instant book, or request-to-book with host approval within 24 hours
  • Payment authorized at booking and captured or released depending on the outcome
  • No night of a listing is ever booked by two guests
  • Search p99 under 500 ms, with calendar changes reflected in search within seconds

Back-of-the-envelope numbers

  • Search: 100M/day ÷ 86,400 s ≈ 1.2K QPS average, ~3.5K at 3× peak
  • Bookings: 500K/day ÷ 86,400 s ≈ 5.8/s average, ~17/s at peak, so the hard part is correctness under contention, not write throughput
  • Calendar rows: 7M listings × 365 nights ≈ 2.6B listing-nights × ~30 B ≈ 77 GB, sharded by listing_id in the source-of-truth database
  • Availability bitmaps: 365 bits ≈ 46 B per listing × 7M ≈ 320 MB, small enough to hold in memory on every search node
  • Photos: 7M × 20 = 140M photos × ~500 KB ≈ 70 TB of originals plus resized variants, served through a CDN
  • Listing metadata: 7M × ~10 KB ≈ 70 GB, so the full search index fits in memory across a small cluster
  • Date filter cost: a city query matching ~20K listings needs ~20K bitmap-mask checks, well under a millisecond

Key components

  • Listing service with a relational store for details, host, and pricing rules; photos in object storage behind a CDN with resized variants
  • Calendar service as the source of truth: one row per listing-night, sharded by listing_id so any booking is a single-shard transaction
  • Search service combining a geo index (geohash or quadtree) with price and capacity filters and per-listing availability bitmaps, then ranking results
  • Change data capture from the calendar into Kafka that updates search availability within seconds of any booking or host edit
  • Booking service that atomically moves every requested night from available to held only if all are free, or relies on a range exclusion constraint
  • Request-to-book holds with a 24-hour expiry: host acceptance captures payment, while a decline or timeout releases nights and voids the authorization
  • Payments integration using authorize-then-capture with the payment processor, with host payouts released after check-in

Common mistakes

  • Reading availability and then inserting a booking in a separate step without locking, so two guests can book overlapping nights
  • Trusting the eventually consistent search index at booking time instead of re-checking the calendar source of truth
  • Relying only on a TTL-based distributed lock, such as a Redis lock, where expiry or process pauses can let two writers through
  • Getting date overlap wrong, such as treating the check-out day as occupied or checking only the first and last night
  • Storing availability as a list of booked ranges and scanning every booking for every search result
  • Charging guests in full on a request-to-book and refunding on decline, instead of authorizing and capturing later
  • Storing nights as UTC timestamps instead of local calendar dates in the listing's time zone

Likely follow-ups

  • How would you support flexible-date searches such as any weekend in October?
  • How would you sync calendars for a host who also lists the same home on other platforms?
  • A guest books a stay 11 months out; how do you handle payment when card authorizations expire within days?
  • How would you rank search results beyond distance and price?
  • How would you support per-night dynamic pricing and minimum-stay rules?
  • How would you handle a sudden spike in searches for a major event in one city?

No community solutions yet

Be the first to publish your solution

Practice ‘Design Airbnb’ with an AI Interviewer

Get scored feedback on your diagram, scalability approach, and trade-offs. Free while we grow — up to 3 full interviews a day.