System Design (High-Level Design) Module 25
Case studies: location, mobility and logistics interview questions
Interview questions on “Case studies: location, mobility and logistics”: warm-ups, then what each harder question tests and how a good answer starts.
Warm-up questions
Short questions with short answers, each answered in full.
-
Fresher to mid
Why do ride-hailing systems keep driver positions in memory instead of a database?
Answered in the lesson Design ride hailing like Uber or Ola: matching
-
Fresher to mid
Why match on pickup time rather than distance?
Answered in the lesson Design ride hailing like Uber or Ola: matching
-
Fresher to mid
Why does a food delivery order need a timeout for the restaurant to accept it?
Questions with model answers
What each question tests, the first step of a good answer and the follow-ups to expect.
-
Mid to senior
Two matcher instances serve one city. A few drivers a day end up assigned to two riders at once. Explain how that can happen, how you would confirm it from the logs, and what you change so that it cannot happen again.
- What it tests
- Seeing a check-then-act race across instances, and fixing it with conditional updates, versions, expiry checked by the store and idempotent accepts.
- First step
- Look for pairs of offers to the same driver created within the matcher's gap between reading the driver and writing the offer, a few hundred milliseconds. If both offers were written, the write trusted a stale read. The fix is one conditional statement that checks the state and the version it read, not a second read before the write.
- Follow-ups
-
- The second matcher's write now fails. What should it do next?
- The driver taps accept just as the offer expires. Who wins?
- Would a distributed lock per driver be a better fix?
From the lesson Design ride hailing like Uber or Ola: matching
Model answer, Pro. Model answers open with any pass; prices are in the notice on this page.Opening the model answers with your pass…
Model answers open with any MySmartCoPilot pass.
- Pro pass · 1 week₹79$2.99
- 30 days₹179$5.99
- 1 year₹1,699$45
One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.
Passes can’t be bought right now, so the model answers can’t be opened at the moment. If you have a pass, enter your licence key.
It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).
In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Senior to staff
A stadium event ends and 30,000 people open the app within ten minutes, all inside four cells, while 400 drivers are nearby. What breaks in the matching path, and how do you keep matching useful for everyone?
- What it tests
- Reasoning about supply against demand first, then hot cells and shards, batch matching under scarcity, honest waiting, shedding by criticality and protecting the ETA service.
- First step
- Compare demand with supply before any design: 30,000 people for 400 drivers is 75 riders per driver, so most riders cannot get a car within minutes whatever the design does. The job is to keep the hot shard and the ETA service healthy, match the drivers who exist well, and tell everyone else the truth quickly.
- Follow-ups
-
- How does batch matching behave at 75 riders per driver?
- Drivers keep arriving from across the city. How does the search change?
- Which features do you switch off first?
From the lesson Design ride hailing like Uber or Ola: matching
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
A user in a sparse suburb searches for pharmacies near them and sees 3 results, although 15 exist within 5 km. The index uses geohash cells at precision 6 and reads the 3 × 3 block around the user. What is wrong, and how do you fix it without slowing down searches in busy areas?
- What it tests
- Understanding what a block of cells covers, a stopping rule that makes nearest-k exact, and choosing cell sizes by density.
- First step
- Work out what the block covers: precision-6 cells are roughly 1.2 km by 0.6 km here, so a 3 × 3 block reaches only about 0.6 km in its narrowest direction from the user. Places beyond that are never read, whatever their rank.
- Follow-ups
-
- Why not just switch every search to precision 5?
- How do you know, while searching, that no unread cell can hold a nearer place?
- The search must also respect a 5 km maximum. How does that change the loop?
From the lesson Design proximity search like Yelp
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
A cafe that opened last week has two 5-star ratings and now ranks above a nearby cafe rated 4.6 from 1,200 ratings. Product wants new places to stay visible but not to jump ahead like this. Design the rating part of the ranking, with numbers.
- What it tests
- Rating confidence with a prior, how the prior weight changes outcomes, and keeping new places discoverable without letting a few ratings dominate.
- First step
- Ask how much evidence each average rests on: two ratings say little, 1,200 say a lot. Rank by an average that is pulled towards the city's average by a fixed number of imaginary ratings, so that a few real ratings move it only a little. Then work both cafes through it with numbers, and choose that number from data.
- Follow-ups
-
- How do you choose the prior weight, and should it differ by category?
- How do you keep brand-new places from never being seen?
- A place's ratings were mostly from three years ago. Should they count the same?
From the lesson Design proximity search like Yelp
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Senior to staff
At lunch, nearby searches in one business district rise to 4,000 a second. Design the caching so that the search servers see at most a few hundred a second from that district, without ever showing a place as open after it has closed.
- What it tests
- Cache key design for location queries, normalising filters, separating time-dependent filters from cached answers, lifetimes and protecting servers when the cache is cold.
- First step
- Decide what a cached answer is: a list of candidates for a cell, a category and normalised filters, long enough to filter and page through. Leave anything time-dependent, such as open-now, out of the key and apply it when the answer is served.
- Follow-ups
-
- What hit ratio do you need, and how do you check that your keys can reach it?
- The cache is emptied at 12:55. What protects the search servers?
- A user's results are personalised. What can still be cached?
From the lesson Design proximity search like Yelp
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
On a bad network a driver's phone sends "complete trip" three times, and one copy arrives ten minutes later, after the rider has already disputed the fare. Design the trip's state changes so that this can never charge twice or reopen a settled trip.
- What it tests
- Idempotency keys with stored results, conditional writes on a version, legal transitions, outbox events, and how disputes and late messages interact with a state machine.
- First step
- Give every command an idempotency key made on the phone and the trip version it saw. The store applies a command with one conditional write only when the move is legal and the version matches, saves the result under the key, and writes one event in the same transaction. A late copy then finds its key and returns the saved result.
- Follow-ups
-
- How long must idempotency keys be kept?
- The late copy carries a different distance. Is that the same command?
- Where does the dispute live, in the trip's states or beside them?
From the lesson Design ride hailing: trips, pricing, payments
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Senior to staff
During evening rain, the surge multiplier in one area jumps between 1.0 and 2.1 from minute to minute, and riders complain that the price changes every time they open the app. Design the surge computation so that prices follow real changes without flapping.
- What it tests
- Windowed supply and demand counts per cell, smoothing and hysteresis with their lag, neighbour smoothing, quote locking, and guardrails such as caps.
- First step
- Separate measurement from publication. Keep counting requests and available drivers per cell in one-minute windows, but publish a multiplier computed from a smoothed ratio, changed only by a meaningful step and held for a few minutes; then measure how many minutes of lag that costs.
- Follow-ups
-
- How do you choose the smoothing constant?
- Two neighbouring cells show 1.0 and 1.8 across one street. What do you do?
- A rider saw 1.4, then 1.8 a minute later. What do they pay?
From the lesson Design ride hailing: trips, pricing, payments
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Senior to staff
Design payment for trips that can be paid by card, from a wallet or in cash, where the final fare is known only at the end and the rider may cancel at any point. Where are the points of no return, and what does each failure undo?
- What it tests
- Modelling payment as a saga with compensable, pivot and retryable steps, card hold rules, idempotent gateway calls, and a double-entry ledger for wallets and cash.
- First step
- Lay out the steps for each method and mark each one as undoable, the point of no return, or retried until it succeeds. Start with the card, where the money is held at booking, captured at the end and released on cancellation, and ask which of those steps can no longer be undone once it has happened.
- Follow-ups
-
- The fare comes out above the hold. What now?
- The capture call times out. Was the rider charged?
- How does cash fit into the same ledger?
From the lesson Design ride hailing: trips, pricing, payments
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Senior to staff
It starts raining at dinner time in a big city. Orders rise by 40 %, 30 % of riders log off and traffic slows. What does the platform do in the next 30 minutes, and how does it decide how far to go?
- What it tests
- Capacity reasoning with Little's law per zone, the levers that change demand and minutes per order, and keeping the critical paths up while being honest with customers.
- First step
- Compute, per zone, the riders the orders now need: orders a minute times the minutes each order keeps a rider busy, divided by the share of time riders can be busy. Compare it with riders online. The gap, not the rain, decides which levers to pull and how hard.
- Follow-ups
-
- Which lever do you pull first, and why that one?
- How do you stop promised delivery times from becoming lies?
- What do you switch off in the apps?
From the lesson Design food delivery like Swiggy
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
When should one rider carry two orders? Describe the rule you would use in real time, and put numbers on what it costs the first customer and what it saves the platform.
- What it tests
- Batching conditions on place, time and direction, protecting the first customer's promise, and measuring rider time as well as delivery time.
- First step
- State the conditions under which a second order fits: picked up from the same or a very near restaurant, ready within a few minutes of the first, and going the same way. Then bound the cost: the first customer's promise must still hold, and their extra minutes are capped.
- Follow-ups
-
- When does batching stop paying?
- Which customer is delivered first?
- How do you know your rule helped?
From the lesson Design food delivery like Swiggy
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
A busy restaurant's tablet goes offline during dinner with 12 orders in progress: some placed, some accepted, some being cooked. What happens to each order, and what do you change in the design?
- What it tests
- Failure handling of one party in a three-party state machine: detection, per-state behaviour, timers, honest communication, and keeping riders from wasting time.
- First step
- Separate the orders by state, because each state means a different promise. Placed orders have no commitment from the restaurant yet; accepted and cooking orders do, and the kitchen is probably still working even though its tablet is silent. Detect the outage from missed heartbeats first.
- Follow-ups
-
- How do you tell an offline tablet from a closed restaurant?
- Riders are already on their way. What do they do?
- The tablet comes back with a queue of stale actions. What then?
From the lesson Design food delivery like Swiggy
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Senior to staff
Your routing service answers routes in under a millisecond with contraction hierarchies built every night from usual speeds. Product now wants routes and arrival times to follow live traffic, with speeds changing every minute. What breaks, and how do you change the design?
- What it tests
- Why preprocessed shortcuts go stale, trading query speed against update speed, cell overlays that are customised per cell, and staging the change safely.
- First step
- Say what a shortcut encodes: the fastest time across a run of junctions under last night's speeds. A jam on one arterial makes every shortcut over it wrong, so either the structure is rebuilt often, or it is replaced by one whose update cost fits a minute of speed changes.
- Follow-ups
-
- How long may applying an update take, and how do you measure it?
- Partners ask for 5,800 pickup times a second, 25 drivers to each pickup. Which structure serves them?
- A bad speed feed marks a highway as stopped. What protects the routes?
From the lesson Design maps, routing and ETA
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
In one city, evening arrival times are 5 to 10 minutes too optimistic on most trips, although the routes look right and the traffic layer shows the jams. How do you find the cause, and what do you change?
- What it tests
- Measuring arrival-time error by its sign and by bucket, separating segment speeds from junction waits and time of day, and fixing bias with history, corrections and re-estimation.
- First step
- Measure before guessing: compare predicted and actual times of finished trips in that city, split by departure time, trip length and road type, and look at the signed error rather than the absolute one. A steady lean in one direction points to something every trip shares, such as junction waits or speeds frozen at departure.
- Follow-ups
-
- The error is worst for trips that start an hour before the peak. Why?
- How do you check that a correction did not just move the error somewhere else?
- Should the app show one arrival time or a range?
From the lesson Design maps, routing and ETA
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
A new map build is published every night. For an hour after each release, tile latency doubles and the load on the tile origin rises tenfold. Explain why, and design a release that avoids it.
- What it tests
- Cache keys for tiles, why a version for the whole set empties every edge, new addresses only for changed tiles, long immutable lifetimes, and the index that maps tiles to addresses.
- First step
- Compare tile addresses before and after a release. If every address carries the build's version, every tile is new to every edge after the release, and all requests miss until the caches refill. Then count how many tiles actually changed: usually a small share.
- Follow-ups
-
- How does the phone learn the new address of a changed tile?
- Which lifetimes and headers do the tiles and the index get?
- A road closure must show within an hour, not after the next nightly build. How?
From the lesson Design maps, routing and ETA
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
An athlete records a morning run on a watch and on a phone app at the same time, and both upload. Another athlete's app retries one upload three times after timeouts. Design how the service recognises each case and what it does with each.
- What it tests
- Idempotent upload APIs, content hashes against keys built from what the data means, overlapping time ranges, and choosing to flag rather than delete when a rule can be wrong.
- First step
- Separate the cases by what is the same. A retry sends identical bytes, while two devices send different bytes for overlapping times. Hash the bytes at the API so that retries are harmless, and compare time ranges per athlete to find two recordings of one workout.
- Follow-ups
-
- A real 20-minute run happened during a long hike. How do you avoid merging it?
- Which of the two recordings counts in the athlete's totals?
- How long do you keep the hashes of past uploads?
From the lesson Design activity tracking like Strava: GPS ingestion
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Fresher to mid
Runners in a city centre report that their 10 km runs show as 11 to 14 km, while runs in parks are right. What is happening, and how do you fix the distance without breaking the parks?
- What it tests
- How GPS error inflates a distance summed from fixes near buildings, filtering jumps by speed, smoothing without crossing gaps, and testing changes against tracks of known length.
- First step
- Look at the raw fixes of a bad run on a map. Near tall buildings, reflected signals make fixes jump tens of metres and back, and each jump adds two long legs. Summing straight lines between noisy fixes overestimates the distance, and the city centre has more and bigger errors than a park.
- Follow-ups
-
- Which speed threshold do you choose, and does it depend on the sport?
- How do you apply the fix to old activities without surprising users?
- Would snapping the track to the road network help?
From the lesson Design activity tracking like Strava: GPS ingestion
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 2 minutes
-
Senior to staff
A security researcher shows that, from a user's public runs, they can find the user's home to within a few metres, although the user hid 200 m around it. Explain how, and redesign the privacy feature.
- What it tests
- Inference from repeated releases, random trimming and moved centres, applying privacy to every derived product, and reprocessing an athlete's history.
- First step
- Every visible track starts where it leaves the same 200 m circle, so the starts of several runs lie on one circle whose centre is the home. Fitting a circle through the starts of a few runs recovers it, so the fix must stop the starts from outlining one fixed circle.
- Follow-ups
-
- What else, apart from maps, can reveal the hidden part?
- The user adds a privacy address today. What happens to last year's runs?
- How do you test that the redesign works?
From the lesson Design activity tracking like Strava: GPS ingestion
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Senior to staff
An athlete switches an activity to private and back to public within ten seconds. An hour later their effort is still missing from the segment's leaderboard, although the activity is public. How can that happen, and how do you design the board updates so that it cannot?
- What it tests
- Ordering of changes per key, at-least-once delivery, idempotent consumers that re-read the source of truth, the order of commit and publish, and partition keys.
- First step
- Write down the sequence: add, remove, add. If the two last messages swap places on the way, or the remove is delivered again after the second add, an updater that applies message contents ends with the effort removed. Ask what the updater trusts: the message, or the stored effort.
- Follow-ups
-
- Why must the change be committed before its message is published?
- Which partition key would you choose, and what does a hot segment do to it?
- How do you find and repair boards that are already wrong?
From the lesson Design activity tracking: segments and leaderboards
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
Cyclists complain that rides on a highway are credited with a segment on the service road beside it, 25 m away. Others say their rides on the service road are not matched at all. How do you fix both without breaking matching elsewhere?
- What it tests
- The corridor trade-off between precision and recall, measuring both on labelled tracks, extra signals such as heading and speed, and guidance for where segments start and end.
- First step
- Name the setting that trades the two complaints: the corridor around the segment. Wider than the gap between the roads, it matches both; much narrower than the GPS error, it misses genuine rides. Measure precision and recall on labelled tracks before changing it.
- Follow-ups
-
- What does 1-second recording change, and what does it not change?
- Could the matcher use more than distance to tell the roads apart?
- How do you roll out a matcher change for millions of past efforts?
From the lesson Design activity tracking: segments and leaderboards
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Senior to staff
A popular climb has 500,000 athletes on its leaderboard. The page must show the top 10 and the viewer's own rank within 200 ms, and boards are stored on disk, not in memory. Design the queries and the data, with numbers.
- What it tests
- Range reads for the top, why rank is a counting problem, stored rank checkpoints and their upkeep, caching, and when an in-memory sorted set is worth its cost.
- First step
- Split the two reads. The top 10 is a range read of the first rows in time order, cheap and cacheable. The rank is the number of faster athletes, which a time-ordered table can only count, about 250,000 rows for a median athlete, so the design must bound that count.
- Follow-ups
-
- How do checkpoints stay right while athletes improve?
- When would you keep the board in a sorted set in memory instead?
- The viewer filters to people they follow. What changes?
From the lesson Design activity tracking: segments and leaderboards
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
All System Design (High-Level Design) interview questions · The System Design (High-Level Design) track