System DesignAdvancedarticle

System Design: Designing Airbnb (Hotel/Home Booking)

How does Airbnb handle millions of search queries and ensure that a home is never double-booked? A technical deep dive into Search, Availability, and Concurrency.

Sachin SarawgiApril 20, 20263 min read3 minute lesson

System Design: Designing Airbnb (Hotel/Home Booking)

Designing a platform like Airbnb or Booking.com involves two distinct technical challenges: Search (helping users find the perfect place) and Concurrency (ensuring that once found, the place can be booked without overlap).

1. Core Requirements

  • Property Listing: Owners can upload photos and details of their homes.
  • Search: Users can search by location, date range, price, and category.
  • Booking & Availability: Checking if a property is available for specific dates and locking it for a user.
  • Payments: Handling secure transactions globally.

2. The Search Architecture

Airbnb is a read-heavy system. Users search far more often than they book.

  • The Search Engine: Use Elasticsearch. It is much faster than SQL for complex filters (e.g., "3 bedrooms, pool, pet-friendly, under 00").
  • Geospatial Search: Use Geohashing (like in our Yelp article) to find properties near a user's target city.
  • Indexing: Property metadata is stored in a relational database (Postgres) and synchronized to Elasticsearch via Change Data Capture (CDC) to ensure search results are up-to-date.

3. Managing Availability (The Inventory Challenge)

Availability is a time-series problem. A property is not just "available" or "not available"; it is available on specific dates.

  • Data Structure: Instead of a simple boolean, store availability as a bitmask or a separate availability table: property_id, date, status (Available/Booked).
  • Querying: To find homes available for May 1st - May 5th, the system queries the database for properties that have no "Booked" status for any of those 5 dates.

4. Preventing Double-Booking (Concurrency)

What if two users click "Book" for the same house at the same time?

  • Step 1: Database Locking: Use a Relational Database (PostgreSQL) with ACID transactions.
  • Step 2: Transaction Flow:
    1. Start Transaction.
    2. SELECT * FROM availability WHERE property_id = 123 AND date BETWEEN ... FOR UPDATE. (This locks the rows).
    3. If all dates are free, insert the booking.
    4. Commit Transaction.
  • Distributed Locking: For better performance, use Redis Redlock to hold a temporary lock on the property while the user is on the payment screen.

5. Scaling Global Search: CDNs and Caching

  • Media: Photos are the largest data source. Use a CDN (CloudFront) to serve images from the edge.
  • Metadata Cache: Popular search results (e.g., "Paris in Summer") are cached in Redis for 5-10 minutes.

6. Real-time Pricing (Dynamic Pricing)

Pricing changes based on demand, seasonality, and occupancy.

  • The Logic: A background worker or stream processor (Flink) calculates the optimal price every few hours and updates the Listing Service.

Summary

Building Airbnb is a balancing act between the "elastic" search requirements (Elasticsearch) and the "rigid" consistency requirements of booking (PostgreSQL). By separating search from the transactional booking path, you can build a system that is both fast and 100% accurate.

📚

Recommended Resources

Designing Data-Intensive ApplicationsBest Seller

The definitive guide to building scalable, reliable distributed systems by Martin Kleppmann.

View on Amazon
Kafka: The Definitive GuideEditor's Pick

Real-time data and stream processing by Confluent engineers.

View on Amazon
Apache Kafka Series on Udemy

Hands-on Kafka course covering producers, consumers, Kafka Streams, and Connect.

View Course

Practical engineering notes

Get the next backend guide in your inbox

One useful note when a new deep dive is published: system design tradeoffs, Java production lessons, Kafka debugging, database patterns, and AI infrastructure.

No spam. Just practical notes you can use at work.

Sachin Sarawgi

Written by

Sachin Sarawgi

Engineering Manager and backend engineer with 10+ years building distributed systems across fintech, enterprise SaaS, and startups. CodeSprintPro is where I write practical guides on system design, Java, Kafka, databases, AI infrastructure, and production reliability.

Keep Learning

Move through the archive without losing the thread.

Related Articles

More deep dives chosen from shared tags, category overlap, and reading difficulty.

System DesignAdvanced

System Design: Designing a Distributed BLOB Store (like S3/GCS)

System Design: Designing a Distributed BLOB Store An object store (BLOB store) is a fundamental building block of cloud infrastructure. Unlike a file system, it provides a simple interface (PUT, GET, DELETE) to store lar…

Apr 20, 20262 min read
Deep Dive
#system-design#object-storage#distributed-systems
System DesignAdvanced

System Design: Designing a Distributed Logging System (TB/Day Scale)

System Design: Designing a Distributed Logging System In a microservices architecture with thousands of containers, logs are scattered everywhere. You need a centralized system that can ingest terabytes of log data every…

Apr 20, 20263 min read
Deep Dive
#system-design#logging#elk-stack
System DesignAdvanced

System Design: Designing a Distributed Message Queue (Kafka Architecture)

System Design: Designing a Distributed Message Queue A Distributed Message Queue is the backbone of modern asynchronous architecture. It allows services to communicate without being tightly coupled. While many use Apache…

Apr 20, 20263 min read
Deep Dive
#system-design#kafka#message-queue
System DesignAdvanced

System Design: Designing a Distributed Search Engine (Elasticsearch)

System Design: Designing a Distributed Search Engine Search is the most common way humans interact with massive datasets. Building a system that can perform full-text search across billions of documents with millisecond…

Apr 20, 20263 min read
Deep Dive
#system-design#search-engine#elasticsearch

More in System Design

Category-based suggestions if you want to stay in the same domain.