Unified Hotel Availability Search Across Three Supplier Feeds
System DesignModel answerLast updated
Design a read-only search service that merges hotel availability from three inconsistent suppliers into one normalized, fault-tolerant response with cross-supplier deduplication.
Scenario
A travel product needs a single search backend that pulls hotel availability from three external suppliers, called S1, S2 and S3. The suppliers disagree on almost everything:
- Response formats and field names differ.
- One uses cursor-based paging, another uses offset paging, and the third behaves differently again.
- Each enforces its own rate limit and a hard cap on concurrent connections.
- Their response times range from about 200 ms to about 2 s.
What the service must do
Functional
- Expose one endpoint that takes a destination and a stay date range and returns a single normalized list of hotel options.
- If a supplier is slow or down, still return what the others provided instead of failing the whole request.
Non-functional
- Resilience: use mechanisms such as circuit breakers and retries to tolerate flaky suppliers.
- Normalization: describe how the three schemas are mapped into one canonical model.
- Observability: measure latency, error rate and data freshness for each supplier.
- Identity resolution: detect when different suppliers list the same physical hotel and merge them.
Scale
- Peak load of 5,000 requests per second.
- Supplier latency between 200 ms and 2 s per call.
- Strict per-supplier limits on concurrent connections.
Expected in your answer
- A high-level architecture sketch.
- The canonical data model.
- How you produce a partial result when one supplier fails or is too slow.
- The pipeline that matches hotels (by name, address and similar attributes) across suppliers.
State your assumptions, do a quick capacity estimate, and discuss trade-offs.
Hints
Hint 1
Estimate load first: multiply request rate by supplier fan-out, then apply Little's Law (concurrency = rate x latency) and compare with the connection quotas. What does this say about calling suppliers live for every user request?
Hint 2
Isolate each supplier behind an adapter with its own concurrency limit, rate limiter and circuit breaker, and give the whole request a single deadline so you can return whatever has finished when time runs out.
Hint 3
Do identity resolution offline: standardize text, block candidates by geographic cell, score pairs, apply thresholds, and keep a versioned mapping lookup that the online path only reads. Never drop an offer just because it is unmatched.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
1. Clarify and size the problem
Assumptions
- Read path only (search and availability, not booking). Prices may be a few minutes stale because booking re-validates them.
- End-to-end p99 target of roughly 1.5 s. The slowest supplier (2 s) cannot always meet it, which is why partial results are a first-class feature.
- Availability and price can be 5 to 15 minutes old. Static content (names, addresses) changes rarely.
Capacity math
- 5,000 RPS x 3 suppliers = 15,000 supplier calls per second.
- Little's Law: concurrency = rate x latency, about 15,000 x 1 s = 15,000 open connections. Supplier quotas are likely in the low hundreds.
- Conclusion: per-request live fan-out cannot work. We need a normalized cache, request coalescing (single-flight) and per-supplier concurrency caps.
- With a 90% cache hit rate, misses fall to about 500 RPS. Coalescing identical in-flight searches reduces distinct upstream calls further, so concurrency per supplier plausibly stays under 100.
2. API and pagination
GET /v1/hotels/search?location=...&check_in=...&check_out=...&guests=...&cursor=...
The response contains search_id, results (hotel plus offers), a partner_status map (for example ok, timeout, stale_cache), a partial flag and next_cursor.
Supplier paging styles never leak to clients. On the first page the aggregator pulls up to N results from each supplier (each adapter handles its own paging), merges, dedups and ranks them, then stores the snapshot under search_id with a short TTL. The client's opaque cursor pages over that snapshot, which keeps ordering stable and avoids a second fan-out for page 2.
3. Canonical model
| Entity | Key fields |
|---|---|
| Hotel | hotel_id, name, normalized address, lat/lng, geohash, stars, chain, phone (E.164), amenities |
| SupplierHotelMapping | (supplier, supplier_hotel_id) -> hotel_id, confidence, match method, mapping version, updated_at |
| Offer | hotel_id, supplier, room type (canonical enum plus raw), rate plan, price (integer minor units plus currency), taxes_included, cancellation policy, units left, fetched_at |
Rules: money as integer minor units with an ISO currency; keep a raw payload passthrough for debugging; every offer carries fetched_at so freshness is measurable.
4. Architecture
Client -> API gateway (auth, rate limit) -> Query service (stateless, autoscaled)
|- Search cache (Redis): key = hash(geo bucket, dates, guests), TTL 5-15 min
|- Single-flight coalescer per cache key
'- Scatter-gather aggregator
|- Adapter S1 \ each adapter: bulkhead (semaphore = quota),
|- Adapter S2 > token-bucket limiter, circuit breaker,
'- Adapter S3 / deadline-aware retry, paging, schema mapper
-> normalize -> mapping lookup (KV) -> merge / dedup / rank -> response
Offline: supplier catalog feeds -> entity resolution -> versioned mapping store
Telemetry: metrics + traces (span per adapter) -> per-supplier dashboards and alerts
Each adapter implements search(query, deadline) -> list[Offer], so the core never sees supplier schemas, auth or paging. Per-supplier bulkheads mean a slow S2 cannot starve threads or connections used by S1 and S3.
5. Partial results
- Compute a global deadline (for example now + 1.2 s), leaving headroom for merge and serialization.
- Launch all adapter calls concurrently and wait until the deadline; take whatever has completed.
- Handle failures explicitly:
- Timeout: respond without that supplier, set its status to
timeout, and let the call finish in the background (inside its bulkhead) to warm the cache. - Circuit open: skip the call, serve stale cached data for that supplier if it exists, and mark it
stale_cache. - 5xx / 429: retry only idempotent calls with exponential backoff and jitter, and only if the remaining budget exceeds that supplier's p50. Cap retries at about 10% of traffic so they cannot amplify an outage.
- Timeout: respond without that supplier, set its status to
- Set
partial: trueso the UI can hint that results are incomplete. - Cache partial responses with a shorter TTL so a bad moment is not pinned for 15 minutes.
Circuit breaker example: open when more than 50% of the last 20 calls fail, stay open 30 s, then half-open with a few probe requests.
6. Identity resolution pipeline (offline)
Run on supplier static-content feeds: daily full load plus hourly deltas.
- Standardize: lowercase, strip stopwords ("hotel", "the"), transliterate, parse addresses, convert phones to E.164, round coordinates.
- Block: only compare hotels in the same geohash cell (about 150 m) and its neighbors, avoiding O(n^2) comparisons.
- Score: features include name similarity (Jaro-Winkler, TF-IDF tokens), haversine distance, phone/postcode/chain equality and star-rating difference. A gradient-boosted classifier trained on labeled pairs outputs a match probability.
- Threshold: above 0.95 auto-merge; 0.80 to 0.95 goes to human review; below 0.80 creates a new canonical hotel.
- Cluster: union-find with the constraint of at most one listing per supplier per cluster, which prevents transitive over-merging.
- Publish: write a versioned mapping table to a low-latency KV store.
Online, the service looks up (supplier, supplier_hotel_id) -> hotel_id and groups offers by hotel so one card can show the best price. Unmapped IDs are shown as standalone results and queued for resolution; never drop inventory because matching failed.
7. Observability
Per supplier: latency histograms (p50/p95/p99), error rate by class (timeout, 5xx, 429, normalization failure), circuit state, quota utilization, cache hit rate, freshness (histogram of now - fetched_at on served offers) and mapping coverage (share of offers with a resolved hotel_id). Use one trace span per adapter and alert on SLOs rather than raw errors.
8. Trade-offs and common mistakes
- Cache vs freshness: longer TTLs protect quotas but risk showing stale prices. Mitigate with re-validation at booking and shorter TTLs for near-term dates.
- Merge precision vs recall: a false merge hides a real hotel or shows wrong rooms; a missed merge only causes a duplicate card. Bias toward under-merging and use review for the gray zone.
- Deadline vs completeness: a tighter deadline lowers latency but returns partial results more often. Tune using per-supplier p95.
- Mistakes to avoid: skipping the capacity math, sharing one thread pool across suppliers, retrying without a budget (retry storms), exposing supplier paging to clients, doing entity matching on the request path, and failing the whole request when one supplier fails.