1. Two-Sided Marketplace Characteristics
Airbnb connects guests with hosts across 7+ million listings globally. Unlike e-commerce where SKUs are fungible, a property is unique: an apartment cannot be booked by two different guests on the same date.
Guests perform heavy search queries filtering by location, price, dates, and amenities. The search engine must exclude booked dates instantly.
2. High-Performance Availability: Calendar Bitmasks
Representing a listing's 365-day calendar as individual database rows creates millions of records that slow down range queries. Instead, we represent a year's availability as a 365-bit bitmask (where 0 = available, 1 = booked).
Checking whether a listing is available for a 5-night stay from day 100 to 105 is an O(1) bitwise AND operation against a precomputed search mask. This bitmask is stored in Redis for sub-millisecond search filtering.
3. Race-Free Reservation Flow with Distributed Locks
When a guest initiates booking, the system creates a temporary hold. To prevent double-booking when two users click 'Instant Book' simultaneously, the service acquires a Redis distributed lock on `listing_id:date_range`.
In the relational database, an optimistic concurrency check (`UPDATE bookings SET status = 'HELD', version = version + 1 WHERE listing_id = ? AND version = ?`) guarantees isolation before releasing the lock.
4. Search Indexing with Elasticsearch
Listings are indexed in Elasticsearch with geospatial geo_point coordinates and faceted filters. Price updates and booking confirmations publish change events to Kafka to update search documents within seconds.
Model this architecture on the HLDForge Canvas
Turn static box diagrams into living, collaborative systems. Drag and drop microservices, Kafka clusters, and cache tiers. Run automated SPOF detection and STRIDE threat modeling in real time.
Written by HLDForge Architecture Team
Principal Marketplace Architect
The HLDForge Architecture Team publishes practical engineering guides, real-world case studies, and high-concurrency blueprints to help engineers build scalable and fault-tolerant software.