Design nearby restaurants search (Yelp, Zomato)
Design a service that answers "what is near me?" (restaurants, shops, stations), ranked by distance and quality, filtered by category and whether they are open now.
About this problem
“Design nearby restaurants search (Yelp, Zomato)” is a core-level problem in the location family. Two dimensions pretending to be one, plus a very high write rate from things that move.
The key challenge: Two hundred milliseconds to answer, and the underlying data barely changes. That makes this one of the most cacheable problems on the site, and one of the easiest to over-engineer.
Time budgets: Query: ~200 ms. Place data freshness: hours. Opening hours: minutes.
The worked solution for Nearby places goes through why those budgets shape the design, stage by stage.
Before you start
You will work this in five timed stages. Here is what each one asks you to think about. None of it is the answer; the answers unlock in the workspace below once you have written your own.
- Stage 1 · Requirements · 5 min
- What is the read:write ratio when the data is places rather than user actions?
- Ranked by distance, or by something else? That question changes boxes.
- How dense is the data? It is not uniform.
- Stage 2 · Actors and lifecycle · 6 min
- Who creates and edits place data? It is usually not one source.
- What does the system decide about which places to show?
- What happens where there are no places at all?
- Stage 3 · Numbers · 6 min
- How many places, and how big is one?
- How many candidates does one query examine? It depends where you are standing.
- How often does the data change?
- Stage 4 · High-level design · 12 min
- How do you turn "within 2 km" into an indexed lookup?
- What do you cache, and what is the cache key?
- Where does "open now" get computed?
- Stage 5 · Deep dive and tradeoffs · 14 min
- Density is the number that stood out. Go there.
- A place near a cell boundary: walk through what happens.
- What happens when a major event fills one small area with users?
Work it through
Five stages, gated. You write your answer for each stage before its model answer unlocks. That is the core of the method.
Done all five? The diagrams, numbers, trade-offs and follow-ups for this problem are on the worked solution page, to check your own design against.
How it is really built
Write your own answer first. Then read how teams who run this at scale describe it. Their constraints were real, and the write-ups often say what their choices cost.
- H3 — indexing the globe ↗Turning two coordinates into one indexable cell id.