Day 27 Exercises

Marketplace & Booking Design

Apply distributed locking, geo-search architecture, and availability calendar design to real marketplace challenges.

Exercise 1🟡 Easy15 min
Double-Booking Prevention
Two users simultaneously try to book the same Airbnb listing for Dec 25-27. User A's request arrives 50ms before User B's. Without concurrency control, both succeed — one host, two guests.

Tasks

  • Why does a simple read-then-write sequence fail under concurrent requests?
  • How does SELECT FOR UPDATE prevent double-booking?
  • What is the trade-off of using pessimistic locking on the availability table?
  • Describe optimistic locking as an alternative. When would you prefer it?
Your Notes
Exercise 2🔴 Medium20 min
Geo-Search Architecture
A user searches "apartments in Paris under €100/night available Dec 24-26". Design the search pipeline that returns results in under 200ms.

Tasks

  • What data store is appropriate for geo-search with price and availability filters?
  • Design the search index document schema (fields + types).
  • How do you efficiently filter by availability (date range) at search time?
  • Where does ML-based ranking fit in the pipeline?
Your Notes
Exercise 3🔴 Medium25 min
Pricing Engine Design
Airbnb uses dynamic pricing: base price + demand multiplier (holiday surge) + supply discount (low competition) + personalization (returning guest). Prices update hourly.

Tasks

  • Design the pricing computation pipeline. Is it synchronous or asynchronous?
  • How do you show users a price estimate before they commit to a booking?
  • What happens if the price changes between "searching" and "booking checkout"?
  • How do you A/B test a new pricing algorithm without breaking production?
Your Notes
Exercise 4🔥 Hard35 min
Global Availability Calendar
Airbnb has 7 million listings globally. Each listing has an availability calendar (365 days). Queries: "is listing X available from Dec 24-26?" must return in under 10ms.

Tasks

  • Design the data model for availability (bitmap? date-range rows? both?)
  • How do you shard the availability data across multiple databases?
  • How do you handle the case where a host blocks dates externally (iCal sync from Booking.com)?
  • Design the concurrent booking window: what happens when 10 users view the same listing simultaneously?
Your Notes