System design interview: design a home rental marketplace like Airbnb
A home rental marketplace lets hosts list places with a nightly calendar and lets guests search by map and dates, then book. The interview is mostly about two things: a search that combines location, dates and filters without scanning every listing, and a booking path that never gives the same night to two guests even when they click at the same moment.
By Evin JohnPublished 8 min read
1. Clarify the requirements
The walk-through describes a generic rental marketplace of this kind, not Airbnb's actual systems. Ask which side of the marketplace the interviewer cares about; most want the guest's search and booking flow.
- Functional: hosts create listings with photos, rules, a nightly price and a calendar; guests search by place, dates and number of guests, filter by price and amenities, view a listing, book and pay; both sides leave reviews after the stay.
- Non-functional: search responds in a few hundred milliseconds; booking is strongly consistent for the dates involved; listing pages and photos load fast worldwide; availability shown in search may lag by seconds.
- Out of scope unless asked: messaging between host and guest, dynamic pricing suggestions, identity verification, experiences and long-term rentals.
2. Estimate the scale
Assumed round numbers, not any company's real figures.
| Quantity | Assumption | Result |
|---|---|---|
| Active listings | 10 million | fits comfortably in one search cluster, split into shards |
| Searches | 300 million a day | about 3,500 a second on average; plan for 10,000 at peak |
| Bookings | 1 million a day | about 12 a second; small, but each must be correct |
| Calendar rows | 10 million listings x 365 nights ahead | about 3.65 billion rows, roughly 110 GB at 30 bytes each |
| Photos | 20 photos per listing, several sizes each | the largest storage item, served from object storage through a CDN |
The ratio is the story: roughly 300 searches per booking. Optimize search for throughput and accept staleness; optimize booking for correctness and accept that it is a little slower.
3. Define the API
GET /v1/search?bbox=lat1,lng1,lat2,lng2&checkIn=2027-03-03&checkOut=2027-03-06&guests=2&maxPrice=180&page=1
-> 200 { results: [{ listingId, title, photo, lat, lng, totalPrice, rating }], nextPage }
GET /v1/listings/{id}?checkIn=...&checkOut=... -> 200 { details, priceBreakdown, available }
POST /v1/bookings/hold { listingId, checkIn, checkOut, guests, idempotencyKey } -> 201 { bookingId, holdExpiresAt, total }
POST /v1/bookings/{id}/confirm { paymentMethodId } -> 200 { status: "confirmed" }
PUT /v1/listings/{id}/calendar { nights: [{ date, status, price }] } (host side)4. Sketch the data model
| Table | Key | Fields |
|---|---|---|
listing | listing_id | host, title, location (lat, lng), capacity, amenities, base price, currency, house rules |
availability | (listing_id, night) | status (open, held, booked, blocked), booking_id, held_until, price override |
booking | booking_id | listing, guest, check-in, check-out, total, status, payment reference |
review | review_id | booking, author, subject, rating, text, published_at |
Sharding by listing_id keeps a listing, its calendar and its bookings on one shard, so the booking transaction never spans machines. Guest-facing queries such as "my trips" go to a secondary table keyed by guest, filled asynchronously.
5. Search by map, dates and filters
A relational query that joins listings to 3.65 billion calendar rows for every map drag would be far too slow. Build a search index instead, fed by change events from the listing and availability tables.
- Geo first. Index each listing's coordinates with a geo index (a geohash or quadtree cell, or the geo point type of a search engine such as Elasticsearch or OpenSearch). A bounding-box query returns candidate listings in the visible map area.
- Dates second. Store availability in the index as a compact structure per listing, for example a bitmap of open nights for the next year. Checking a three-night stay becomes a bitwise test, not a join.
- Filters and price. Guests, amenities and nightly price are ordinary indexed fields. Total price for the dates needs per-night overrides, so compute it for the top results only, not for every candidate.
- Rank. Order by a relevance score that mixes distance from the map center, rating, price fit and conversion history. Ranking models are their own topic; one sentence is enough unless asked.
The index lags the database by a few seconds. That is acceptable because the booking step re-checks the real calendar. Typeahead for place names ("Lisb...") is a separate small service, the same shape as search autocomplete.
6. Hold and confirm without double booking
Two guests can request overlapping dates in the same second. With one row per night, a single conditional update claims every night in the range only if all of them are free. If fewer rows change than the number of nights, someone else got there first, and the transaction rolls back.
BEGIN;
UPDATE availability
SET status = 'held', booking_id = :booking, held_until = :now_plus_15min
WHERE listing_id = :listing
AND night >= :check_in AND night < :check_out
AND (status = 'open' OR (status = 'held' AND held_until < :now));
-- application: if rows_changed != nights_requested then ROLLBACK else COMMIT- Check-out night is excluded (
night < :check_out), so a stay ending on the 6th and one starting on the 6th do not collide. - Expired holds are reclaimable in the same statement, so no cleanup job has to run before dates become bookable again. A background sweep still resets old holds for tidiness and for the search index.
- Confirm re-checks ownership. Before charging, the confirm step verifies that every night still carries this
booking_id; an expired hold that lost a night to another guest fails cleanly instead of charging for a partial stay. - Concurrency. In PostgreSQL at the default isolation level, a second update waits for the first one's row locks and then re-checks its WHERE clause, so it sees the nights as held. Say which database you assume and how it behaves.
The ticket booking walk-through covers the hold pattern under a flash crowd, with a waiting room. Rentals rarely see that rush, so here the per-listing row locks are enough.
7. The architecture
- Clients
- Guest app and web
- Host app and web
- Edge
- CDN for photos
- API gateway
- Services
- Search
- Listing and calendar
- Booking
- Payments and payouts
- Reviews
- Data
- Sharded relational DB
- Search index (geo + availability)
- Object storage
- Async
- Change-event queue and indexer
- Notifications
- Payout scheduler
Payments follow the usual rules: an idempotency key on every charge, a ledger, and reconciliation with the provider. The payment system walk-through covers those. What is specific here is timing: the guest pays at booking, while the host's payout is scheduled for after check-in, so a cancellation before arrival refunds the guest without clawing money back from the host.
8. What breaks, and what you do about it
| Failure | Effect | Mitigation |
|---|---|---|
| Search shows a listing that was just booked | Guest clicks, then sees "not available" | Accept it and re-check on the listing page; keep indexing lag low with change events instead of nightly rebuilds |
| Payment provider times out after a hold | Dates locked but outcome unknown | Retry with the same idempotency key; the hold expiry frees the nights if the booking never confirms |
| Host also lists on another site and gets booked there | Real double booking across platforms | Calendar sync imports and exports; block synced nights quickly; a cancellation policy for the rare conflict |
| Popular city on a holiday weekend | Search spike on a few geo cells | Cache search results per cell, dates and filters for a short time; scale the search tier horizontally |
| Shard with a very large host | One shard gets most writes | Shard by listing, not host, so a host with thousands of listings is spread out |
9. Trade-offs to discuss
- Per-night rows or date ranges. Ranges (a booking from the 3rd to the 6th) use fewer rows but need interval overlap checks or exclusion constraints. Per-night rows cost more storage and make the check trivial.
- Hold length. A long hold protects a slow payer but blocks other guests; a short one causes failures at payment. Around 10 to 15 minutes is a common choice for a design like this.
- Instant book or host approval. Approval adds a pending state that holds dates for hours, which changes the hold logic and the search index.
- Price in the index or computed later. Indexing a nightly price enables price filters; exact totals with fees, taxes and discounts are computed for the shortlist only.
- Search freshness. Pushing every calendar change into the index costs write load; batching it adds staleness. A few seconds is a reasonable middle.
10. How to talk through it in the interview
Fictional example
- Interviewer
- Two people book the same cabin for overlapping weekends at the same time. What happens?
- Candidate
- Both requests reach the booking service, which runs one conditional update on the cabin's night rows in a transaction. The first one changes all three rows and commits. The second waits on the row locks, then finds one night already held, changes only two rows, sees the count is short and rolls back. That guest gets a clear "dates just taken" message.
- Interviewer
- And the search results they saw?
- Candidate
- The index catches up within seconds from the change event. Until then, the listing page and the booking step both read the real calendar, so stale search costs a click, not a wrong booking.
- Draw search and booking as two separate paths with different stores, and explain the ratio that justifies it.
- Write the conditional update on the board; it is short and shows you know the mechanics.
- Mention payouts after check-in; it shows you see a two-sided marketplace, not a shop.
Running a mock of this design with Natively
Ask a friend to play the interviewer on a call and to interrupt with the double-booking and stale-search questions. Natively, open on your Mac or Windows PC, keeps a transcript of the conversation and can propose talking points for whatever was just asked, which helps you notice when an answer skipped hold expiry or payout timing. It can also sketch the search and booking paths as a diagram if you ask, so you can compare it with your own board. Go through the saved notes the next day and practice only the parts you fumbled.
Questions people ask
How do you prevent double booking in an Airbnb system design?
Store one availability row per listing per night and claim the whole stay with one conditional update inside a transaction: set the nights to held only where they are open or their hold has expired. If fewer rows change than the number of nights, roll back and tell the guest the dates were just taken.
How does Airbnb-style search combine location and dates?
A search index holds each listing's coordinates in a geo index plus a compact record of open nights, such as a bitmap for the coming year. A map query finds listings in the visible area, the date check is a fast bitwise test, and exact prices are computed only for the top results.
Should search results be strongly consistent with bookings?
No. Searches outnumber bookings by a wide margin, so the index is updated from change events and may lag by a few seconds. The listing page and the booking step read the real calendar, so a stale result costs the guest a click, never a wrong booking.
When does a host get paid in a rental marketplace design?
A common design charges the guest at booking and schedules the host's payout for shortly after check-in. That keeps refunds simple when a guest cancels before arrival, since no money has left the platform yet. Each charge and payout uses an idempotency key and is reconciled with the payment provider.
Where to go next
Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.
Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.
