Katkat

Design a Rental Marketplace Backend

AirbnbBackend Engineer · Onsite

Last updated

This problem tests your ability to design a distributed, high-scale rental marketplace platform, focusing on concurrency control for bookings, efficient geo-spatial searching, and data consistency.

Scenario

Design a backend architecture for a global vacation rental marketplace similar to Airbnb. The system must support millions of listings and thousands of concurrent booking requests while maintaining high availability.

Requirements

Functional

  1. Search: Users can search for listings by location (lat/long), dates, and occupancy.
  2. Booking: Users can reserve a listing for specific dates. The system must ensure no double bookings.
  3. Listings: Property owners can create, update, and manage their listings and availability calendars.

Non-Functional

  1. Availability: The search and booking services must be highly available.
  2. Consistency: Strong consistency is required for the booking process to prevent overbooking.
  3. Latency: Search results should return under 200ms.

Expectations

Your design should cover:

  1. Data Model: Database schemas for Listings, Bookings, and Availability calendars.
  2. API Design: Core endpoints for search and booking.
  3. System Architecture: High-level components (e.g., search indexing, booking service, databases, caching).
  4. Database Strategy: How do you handle high-frequency reads (searching) versus high-consistency writes (bookings)?
  5. Scaling: Strategies for handling geographic traffic surges and peak booking windows.

Hints

Hint 1

Consider using a quad-tree or Geohash-based spatial index to efficiently query listings within a specific radius.

Hint 2

For the booking service, address the 'double-booking' problem by implementing optimistic locking or using a distributed lock manager on the specific property's calendar dates.

Hint 3

Decouple the read-heavy search traffic from the write-heavy booking traffic using a combination of a search engine (like Elasticsearch) and a strongly consistent relational database.

Follow-up questions

  • How would you handle global consistency if a user in Tokyo and a user in New York attempt to book the last available slot for a listing simultaneously?
  • How would you design the system to provide personalized ranking for search results using machine learning features?
  • If a major cloud region fails, what is your strategy for disaster recovery while maintaining the integrity of ongoing bookings?