Hotel booking
0-day streakReview

Your progress

Level 1

0 XP100 XP to level 2
0day streak
0best streak
0topics started
0cards reviewed
    Review cards

    Progress is stored only in this browser. No account is required.

    Design a hotel booking system (Airbnb): the 60-second story

    Design a hotel booking system

    You don’t buy a room. You buy a run of nights.

    Priya wants a Goa villa for 29 Dec–2 Jan; Arjun, 31 Dec–3 Jan. Two nights overlap; one must lose.

    267

    reads for every booking

    100M searches and 300M listing views a day, for 1.5M bookings. Browsing may be seconds stale; only the booking must be exactly right.

    Priya and Arjun press Reserve together

    Bad: Check, then insert

    Both check before either inserts; the villa sells twice.

    Good: One conditional update

    Add one per night only where reserved < total. Any night full? Roll back and refuse.

    A villa is just a hotel with one room

    One row per unit per night. A villa’s total is 1; a Deluxe King room type’s is 40. Same table, same booking path.

    Counters never pick rooms. Could a three-night guest find no single room free throughout?

    The trick

    No. Rooms needed = the most stays on any one night, and the counter caps that at 40.

    Four nights in Goa, three different prices

    A season rule, a New Year’s Eve override and a Friday uplift make ₹52,000; fees and tax make ₹59,400. Reserve freezes it in a signed quote.

    Booked on one site at 10:05. Booked again at 10:40.

    iCal sync pulls other sites’ calendars now and then, up to two hours late, and can only say “closed”, never “3 of 40 left”.

    The fix: push changes, don’t pull calendars

    1. One channel manager owns counts for every site
    2. It pushes each change; apply them in order
    3. Push your bookings out within seconds
    4. Rare clash: move the later guest nearby

    Remember

    One counter per unit per night, changed by one conditional update. Every copy, from search to other sites, refreshes from the change stream.