πŸŽ‰ 75% of content is free forever β€” Unlock Premium from $10/mo β†’
CW
Search courses…
πŸ’Ό Servicesℹ️ Aboutβœ‰οΈ ContactView Pricing Plansfrom $10

Design Airbnb

System Design ProblemsMarketplace Systems🟒 Free Lesson

Advertisement

System Design Problems

Design Airbnb

Airbnb serves 150M+ users across 220+ countries with 7M+ listings. This design covers search with geo-filtering, booking with availability management, reviews, and payment processing.

  • Scale β€” 150M+ users, 7M+ listings, 1B+ nights booked
  • Search β€” Geo-filtered search with 100ms latency
  • Booking β€” Double-booking prevention with distributed locks

Airbnb's core challenge is building a two-sided marketplace with trust, search, and real-time availability.

Requirements Clarification

Functional Requirements

  1. Search listings by location, dates, and filters
  2. View listing details with photos and reviews
  3. Book accommodations with availability check
  4. Leave reviews and ratings
  5. Messaging between hosts and guests
  6. Payment processing with escrow
  7. Host management dashboard

Non-Functional Requirements

  1. Availability: 99.99% uptime
  2. Latency: Search results < 500ms
  3. Consistency: Strong for bookings (no double-booking)
  4. Scale: 150M users, 100K searches/minute

Airbnb's critical constraint: No double-booking. Unlike social media where eventual consistency is acceptable, a booking conflict destroys trust. This requires strong consistency for the booking path.

Back-of-the-Envelope Estimation

Search QPS

QPSsearch=100KΓ—6060=100KΒ QPS\text{QPS}_{\text{search}} = \frac{100K \times 60}{60} = 100K \text{ QPS}

Here,

  • 100K100K=Searches per minute
  • 100K100K=Queries per second

Storage Estimation

Listing data:

  • 7M listings x 10KB metadata = 70 GB
  • 7M listings x 50 photos x 2MB = 700 TB (object storage)

Review data:

  • 200M reviews x 2KB = 400 GB

Booking data:

  • 1B bookings x 1KB = 1 TB

High-Level Architecture

ClientsAPI GatewaySearch SvcBooking SvcListing SvcPayment SvcReview SvcMessaging SvcMessage Queue (Kafka)ElasticsearchMySQL (Bookings)Redis (Availability)S3 (Photos)Stripe/PayPal

Search Architecture

DfGeo-Filtered Search

Airbnb's search uses Elasticsearch with geo-point queries. Listings are indexed by location using a quadtree structure. The search supports filtering by price, amenities, ratings, and availability.

Geo Distance Query

d=2Rβ‹…arcsin⁑(sin⁑2Δϕ2+cos⁑ϕ1cos⁑ϕ2sin⁑2Δλ2)d = 2R \cdot \arcsin\left(\sqrt{\sin^2\frac{\Delta\phi}{2} + \cos\phi_1 \cos\phi_2 \sin^2\frac{\Delta\lambda}{2}}\right)

Here,

  • RR=Earth radius (6371 km)
  • phiphi=Latitude
  • lambdalambda=Longitude

Booking System: Preventing Double-Bookings

DfPessimistic Locking with Optimistic Fallback

Airbnb uses a two-phase approach: (1) Redis distributed lock on listing+dates prevents concurrent bookings, (2) Database unique constraint on (listing_id, date) as fallback, (3) If both fail, reject the booking.

Availability Check

Available=Β¬βˆƒb∈Bookings:b.listing=L∧b.dates∩Dβ‰ βˆ…\text{Available} = \neg \exists b \in \text{Bookings}: b.listing = L \wedge b.dates \cap D \neq \emptyset

Here,

  • LL=Listing ID
  • DD=Requested date range
  • bb=Existing booking

Optimistic locking alone is insufficient for high-contention scenarios (popular listings during peak season). The Redis distributed lock prevents the thundering herd problem.

Trust and Safety

DfTwo-Sided Review System

Airbnb uses a two-sided review system where both host and guest review each other. Reviews are published simultaneously after both parties submit or after 14 days. This prevents retaliatory reviews.

Data Model

Booking Schema

Booking=(booking_id,listing_id,guest_id,check_in,check_out,status,total_price)\text{Booking} = (booking\_id, listing\_id, guest\_id, check\_in, check\_out, status, total\_price)

Here,

  • bookingidbooking_id=Unique booking identifier
  • checkin/outcheck_in/out=Date range
  • statusstatus=pending/confirmed/completed/cancelled

Practice Exercises

  1. Search: Design a search system that returns results in < 100ms for 100K QPS.
  2. Availability: How would you handle a situation where two guests try to book the same listing at the exact same time?
  3. Payments: Design an escrow system where payment is held until checkout.
  4. Scale: How would you handle a flash sale where 100K users search for the same city simultaneously?

Key Takeaways:

  • Search uses Elasticsearch with geo-point indexing
  • Booking requires distributed locks to prevent double-booking
  • Two-sided review system builds trust
  • Escrow payment model protects both hosts and guests
  • Geo-filtered search is the core query pattern

What to Learn Next

-> Design Uber Real-time location and dispatch.

-> Design Amazon E-commerce at scale.

-> Idempotency Handling duplicate requests.

-> Saga Pattern Distributed transactions.

-> Outbox Pattern Reliable event publishing.

-> Circuit Breaker Preventing cascade failures.

⭐

Premium Content

Design Airbnb

Unlock this lesson and 900+ advanced tutorials with a Premium plan.

🎯End-to-end Projects
πŸ’ΌInterview Prep
πŸ“œCertificates
🀝Community Access

Already a member? Log in

Need Expert System Design Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement