Dev Skills

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.

  1. 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.
  2. 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?
  3. 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?
  4. 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?
  5. 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?
Prefer to read first? The worked solution, end to end →

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.

Loading your progress…

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.

Before you leave
Try this problem again in a week without reading anything. Comparing what you write then with what you wrote today shows you what stuck.
Stuck, or new to this?Read the full worked solutionAll five stages end to end, with the diagrams and the costs, written out the way you would say it. Best read after you have had a go.Read it →

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.