Design a Rental Marketplace Backend
AirbnbBackend Engineer · OnsiteLast 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
- Search: Users can search for listings by location (lat/long), dates, and occupancy.
- Booking: Users can reserve a listing for specific dates. The system must ensure no double bookings.
- Listings: Property owners can create, update, and manage their listings and availability calendars.
Non-Functional
- Availability: The search and booking services must be highly available.
- Consistency: Strong consistency is required for the booking process to prevent overbooking.
- Latency: Search results should return under 200ms.
Expectations
Your design should cover:
- Data Model: Database schemas for Listings, Bookings, and Availability calendars.
- API Design: Core endpoints for search and booking.
- System Architecture: High-level components (e.g., search indexing, booking service, databases, caching).
- Database Strategy: How do you handle high-frequency reads (searching) versus high-consistency writes (bookings)?
- 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?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.