Airbnb

Home rental marketplace

Design a marketplace where hosts list homes and guests search by place and dates, book without ever double-booking a night, pay, and review each other.

Overview

A home rental marketplace connects hosts, who list homes, with guests, who search for a place to stay on particular dates. Unlike an online store, the inventory is not a count of identical items: each home on each night is unique, and it can be sold exactly once. Two guests must never both be confirmed for the same night.

That makes the design split cleanly. Search must answer 'what is free near here on these dates for four people?' over millions of listings, quickly, while hosts keep changing prices and calendars. It can be slightly stale, because nothing is sold from a search result. Booking must be exactly right, but it is a small, per-listing workload. The interviewer will test whether you keep the two apart and still make them agree.

Questions to ask first

  • How many listings, searches and bookings? — 7 million listings, 200 million searches and 400,000 bookings a day
  • How do guests search? — A map area or place, check-in and check-out dates, number of guests, filters
  • Can a guest book at once? — Yes for Instant Book listings; otherwise the host approves a request
  • When is money moved? — The guest pays when the booking is confirmed; the host is paid after check-in
  • Reviews? — Both sides review each other after the stay
  • How fresh must search be? — Seconds behind is fine; booking rechecks everything

What you will be able to do

  • Answer a map-plus-dates search with a geo index, precomputed availability and a final exact check.
  • Keep the search index fresh from a change stream, and say why booking never trusts it.
  • Make double-booking impossible with a database constraint on listing-nights.
  • Design Instant Book and booking requests, including holds that expire.
  • Take payment exactly once and pay hosts later; run double-blind reviews.

Key concepts

  • Geo search
  • Availability calendar
  • Two-stage retrieval
  • Search index freshness
  • Double-booking prevention
  • Booking requests with expiry
  • Idempotent payments
  • Delayed payout
  • Double-blind reviews

Functional requirements

  • Hosts create listings with photos, capacity, price and a calendar
  • Guests search by map area or place, dates and number of guests, with filters
  • Guests see a listing page with its calendar and the total price for their dates
  • Guests book instantly or send a request the host accepts or declines
  • Guests pay at confirmation; hosts are paid after check-in
  • After the stay, guest and host review each other

Non-functional requirements

  • Search returns in under 500 ms at p99 (a target we chose)
  • A night is never confirmed to two guests
  • Search reflects calendar and price changes within seconds
  • A guest is never charged twice for one booking
  • Booking stays available during the busiest travel seasons, at a few times average load

Interview questions

  • How do you prevent double-booking?
  • How does search handle dates as well as location?
  • How do you keep the search index fresh with thousands of updates a second?
  • How does a booking request that needs host approval work?
  • How do you avoid charging a guest twice?
  • When is the guest charged and when is the host paid?
  • How do reviews stay honest?
  • How do you shard the data?

Sign up free to read the full topic

More System Design topics

Start free on Cariara · Coding problems · System design studio