Asked at
URL Shortener (TinyURL)
Asked from Junior level upFoundations & Storage
Distributed Rate Limiter
Asked from Mid level upAPI Gateway & Security
Distributed Key-Value Store
Asked from Senior level upFoundations & Storage
Distributed Notification Service
Asked from Mid level upMessaging & Queues
Distributed Web Crawler
Asked from Mid level upDistributed Systems
Metrics & Monitoring Platform
Asked from Senior level upObservability & Time-Series
Real-Time Chat App (like WhatsApp or Slack)
Asked from Mid level upReal-Time & WebSockets
Social News Feed (like X/Twitter)
Asked from Mid level upSocial & Feed Systems
Ride-Hailing App (like Uber)
Asked from Senior level upGeospatial & Real-Time
Low-Latency Stock Exchange Matching Engine
Asked from Staff level upFintech & Low Latency
Global Video Streaming Platform (like YouTube or Netflix)
Asked from Senior level upMedia & Streaming
Distributed Hotel & Ticket Reservation System
Asked from Mid level upE-Commerce & Transactions
Shared Document Editor (like Google Docs)
Asked from Staff level upReal-Time & Distributed State
Game Leaderboard
Asked from Junior level upCaching & Data Structures
File Sync Service (Dropbox / Google Drive)
Asked from Mid level upStorage
Payment System
Asked from Senior level upPayments & Transactions
Ad Click Aggregation
Asked from Senior level upStream Processing
AI Support Assistant (RAG)
Asked from Senior level upAI Systems
LLM Inference Platform
Asked from Senior level upAI Systems
Enterprise Semantic Search
Asked from Mid level upAI Systems
AI Code Completion
Asked from Senior level upAI Systems
LLM Gateway
Asked from Senior level upAI Systems
AI Agent That Takes Actions
Asked from Senior level upAI Systems
LLM Evaluation Platform
Asked from Senior level upAI Systems
AI Document Processing Pipeline
Asked from Mid level upAI Systems

Design a Ride-Hailing App (like Uber)

Asked from Senior level upDomain: Geospatial & Real-Time
Design it: check it against goals
Concepts to know first:

Design a ride app that tracks drivers as they move, finds the drivers near a rider, and sends one of them to the rider.

An analogy

Think of a ride-sharing service like air traffic control for taxi drivers. Your phone shares your GPS pin, and a radar map pairs you with the closest idle cab within a 2-mile radius.

Where this design ends up. This is version 3 of 3. Part 5 builds it up from version 1 and says why each part was added.
  1. Clients
    • Rider app
    • Driver app
  2. Entry
    • Gateway
  3. Services
    • Ride matching service
    • Location workers
  4. Queues, caches
    • Location stream
    • Geo index
    • Driver lock
  5. Data, outside
    • Trips database
    • Push service

1. Requirements and scope

Functional Requirements
  • Drivers broadcast GPS location every 4 seconds.
  • Riders can request nearby available drivers within a 5km radius.
  • Match rider with best available driver and track trip progress in real time.
Non-Functional Requirements & SLAs
  • Sub-second driver discovery latency.
  • High availability for matching and trip lifecycle.
  • Accurate geospatial proximity filtering.
Key Traffic Assumptions: 5 million active drivers each send their location every 4 seconds: 5,000,000 ÷ 4 = 1.25 million updates a second.

2. Back-of-the-envelope numbers

Writes and reads each second
  • Writes: 1,250,000 location updates a second (93%)
  • Reads: 100,000 driver searches a second (7%)

Write-heavy: about 13 writes for each read. A queue and a store that is fast at writes help most here.

Write Throughput
1,250,000 location updates/sec
Read Throughput
100,000 driver search queries/sec
Storage Growth
PostGIS trip history: ~50M trips/day (5M drivers × ~10/day) × ~200B ≈ 10GB/day; breadcrumbs every 30s (~30/trip) × ~40B ≈ 60GB/day; ~70GB/day ≈ ~25TB/year
RAM Cache Footprint
Redis geo index for 5M active drivers: about 100 bytes each, roughly 0.5 GB (an estimate; measure it)

3. API

POST/api/v1/drivers/locationDriver GPS ping: { driverId, lat, lng, bearing, status }
GET/api/v1/riders/nearby-driversFind nearby drivers: ?lat=37.77&lng=-122.41&radius=5km
POST/api/v1/trips/requestRequest ride: { riderId, pickupLat, pickupLng, dropoffLat, dropoffLng }

4. Data model and storage

Storage Strategy: Redis with geospatial indexes (GEOADD / GEOSEARCH) + PostgreSQL PostGIS for trip history.
REDIS GEO index key="drivers:active", member="{driverId}", longitude, latitude

5. The design, in three versions

Version 1: Relational PostGIS Queries

Each driver location is written straight into PostgreSQL, with PostGIS for map searches.

Ride-Hailing App (like Uber): Version 1: Relational PostGIS Queries Version 1 of 3

The picture follows one request through the parts of this version, in order. Under it, switch a part off to see what the request does without it.

One request, step by step

Each numbered arrow is one step. Press "Simulate Request Flow" to follow them one at a time.

Rider appRide matching serviceTrips database123
  • The order of the steps
  • A request or its reply

The parts: switch one off

1. Clients

Rider appasks for a ride

2. Services

Ride matching servicepicks a driver

3. Data, outside

Trips databaserides and prices

The steps in words0 of 3 steps shown

  1. Rider app to Ride matching serviceHTTPS · 3 ms

    A rider asks for a ride near a point on the map.

  2. Ride matching service to Trips databasequery · 8 ms

    It asks PostgreSQL for the drivers within 2 km.

  3. Ride matching service to Rider appreply · 20 ms

    The nearest driver goes back to the rider.

Why this version
Rich spatial querying capabilities.
Next bottleneck
One PostGIS database cannot take 1.25 million location writes a second: each write also updates a spatial index.

Write path, read path and failures

Each path follows one request through the final design (version 3), one hop at a time.

Write pathA driver reports a location

  1. Driver app
  2. Location service
  3. Geo index
  4. Trip database
  1. Driver app to Location service

    Every 4 seconds the driver's app sends its position.

  2. Location service to Geo index

    The service turns the position into a cell id, a small hexagon on the map. It updates that driver's entry in memory.

  3. Location service to Trip database

    For a driver on a trip, positions are also saved in batches for the trip history.

Read pathA rider requests a ride

  1. Rider app
  2. Ride matching engine
  3. Geo index
  4. Driver lock
  5. Driver app
  1. Rider app to Ride matching engine

    A rider asks for a ride from a pickup point.

  2. Ride matching engine to Geo index

    The engine finds the rider's cell and its neighbours, and lists the free drivers inside them.

  3. Ride matching engine to Driver lock

    It picks the best driver and tries to reserve them. The reserve step changes the driver from available to reserved, only if still available.

  4. Ride matching engine to Driver app

    It sends the offer to the driver, who has about 15 seconds to accept.

  5. Ride matching engine to Rider app

    On accept, the trip is saved and both apps start to show each other's position.

What breaks, and what happens then

  • Two riders are matched to the same driver at once

    What users see
    Both would be told the driver is coming.
    What the design does
    The reserve step succeeds for one request only. The other request moves to the next nearest driver.
  • A location server restarts

    What users see
    Its positions in memory are gone.
    What the design does
    Drivers report every 4 seconds, so the index refills within seconds. No backup of positions is needed.
  • The driver does not answer the offer

    What users see
    The rider waits.
    What the design does
    The reservation expires after about 15 seconds, and the engine offers the trip to the next driver.
  • One city has a sudden rush

    What users see
    The servers for those cells get far more load than the others.
    What the design does
    Cells are spread over servers with a hash ring, and busy cells can be split across more servers.

6. Deep dives

Geohash vs Google S2 vs Uber H3
Geohash cuts the map into rectangles, so corner neighbours are farther away than edge neighbours. Google S2 projects the Earth onto a cube and numbers its cells along a Hilbert curve, so nearby cells usually get nearby numbers. Uber H3 uses hexagons: all six neighbours are about the same distance away, so rings of cells cover a nearly round area.

7. Follow-up questions

  • How do you prevent two nearby riders from booking the same driver? (Answer: Change the driver from AVAILABLE to RESERVED in one atomic step, a compare-and-set, with a 30-second expiry. Only one request can win.)

What it costs

Location updates are the load: 1.25 million a second. Almost all of them are overwritten within seconds, so keep them in memory and save only a sample to disk. Sending updates less often while a driver waits also cuts the bill.

Another way to design it

Geohash cells in Redis or a PostGIS query can replace the H3 ring. Both are simpler and work well for one city. The custom ring pays off when many cities share one fleet of servers.

8. How answers are judged

A passing answer at Mid level. A complete design with numbers: about 1.25 million location updates a second and 100,000 search queries a second. It explains a geospatial index such as geohash and goes deep on one part, such as matching.

How each level is judged
What is judgedJuniorMidSeniorStaff
BreadthHow much of the system does the answer cover?Names the core parts: clients, servers, a database and a cache.Covers the whole main flow, from the request to the stored data and back.Builds a complete design without being led through it.Covers the system, the systems around it and who owns each part.
DepthHow far does it go into the hard parts?Explains what each part does and why it is there.Goes deep on one part, such as the database or the cache.Goes deep on the two or three riskiest parts.Goes deepest where the risk is largest, and explains why the risk is there.
DrivingWho leads the conversation?Follows the interviewer, step by step.Moves forward alone, with an occasional nudge.Leads the conversation from start to finish.Changes the problem when the question asked is not the right one.
Trade-offsAre choices compared and justified?Names more than one option.Says why one option was picked over another.Compares options in detail, with what each one costs.Ties each choice to cost, speed and risk for the business.
Unclear questionsWhat happens when the question is vague?Answers the questions that are asked.Asks questions to make the problem clear.Sets the scope and says what is left out.Questions the assumptions behind the problem itself.
ScopeWhat does it consider beyond the normal path?Covers the normal path, when everything works.Adds what happens when a part fails.Adds growth: what breaks at ten times the load, and the fix.Adds abuse, cost and the daily work of running the system.

Requirements and scope

Strong answer
Before I design, I want to check the scope. Riders request nearby drivers within 5km, and drivers ping GPS every 4 seconds. Does 'best driver' mean nearest, or does it also weigh rating and estimated arrival? I will assume nearest-available matching, sub-second search, and that trip history can be eventually consistent.
Weak answer
Riders request a nearby driver, and I match them to whichever available driver is geographically closest, full stop. Let me start building the location index and the matching API.

Shows: Unclear questionsThe difference: The weak answer assumes 'best driver' means only nearest, without asking whether rating or estimated arrival time should factor in too.

Estimates

Strong answer
5 million drivers pinging every 4 seconds is 1.25 million location updates a second, kept only in memory, not written per ping. Nearby-driver searches run about 100,000 a second. Trip history in PostGIS adds roughly 25 TB a year, far less than logging every ping would.
Weak answer
Each of the 1.25 million location pings a second needs its own row. So I would size Cassandra for 1.25 million durable writes a second, replicated three times.

Shows: DepthThe difference: Writing every ping to a durable database wastes capacity. The strong answer keeps live location in memory; only the index must sustain that rate.

Core design

Strong answer
Drivers' pings write into a Redis GEO index sharded by region. That spreads citywide load across many nodes, though one dense cell can still land on a single node. A rider's search queries neighbouring cells for available drivers, and reserving one is an atomic compare-and-set from AVAILABLE to RESERVED with a short TTL.
Weak answer
Every driver location update writes to one Redis instance holding a single GEO index for the whole world. A rider's search runs one GEORADIUS query against that same index.

Shows: DepthThe difference: One Redis instance cannot take 1.25 million writes a second alone. Sharding the index by region spreads that load across many nodes.

Deep dive

Strong answer
The hard part is uneven density, not raw volume. A fixed-size cell downtown can hold thousands of drivers while a nearby rural cell sits empty, so its one node overloads. I would use finer cells where density is high, split a hot cell further, and add read replicas for that node.
Weak answer
I would pick one cell size everywhere, say a 1km geohash, and give each cell to a single shard, however many drivers it holds.

Shows: DepthThe difference: Assuming even density means a busy downtown cell overloads its one shard, while a rural cell's shard sits idle. Finer cells and replicas even out a hot cell's load instead.

Failures and trade-offs

Strong answer
If a node holding part of the in-memory index crashes, its drivers vanish from search until their next ping, at most 4 seconds later. We never treated that memory as durable. A short heartbeat also marks a driver who goes offline mid-trip unavailable within seconds.
Weak answer
If a node holding driver locations crashes, I would replicate every update to another node synchronously first, so no location update is ever lost.

Shows: Trade-offsThe difference: Synchronous replication of 1.25 million updates a second adds cost the design does not need, since a stale driver re-pings within 4 seconds anyway.

We wrote this guide in our own words, informed by public interview guides such as AlgoMaster and Hello Interview. We are not connected to either site. Interviewers differ. The guide and the example answers show the direction each level takes, not a checklist.

10. Check your design with your own AI

Write your design first. Then copy this prompt into the AI chat you already use, and add your design at the end. It asks for a score in each area, one fix for each, and two follow-up questions.

The site sends nothing anywhere. An AI review can be wrong, so check what it says against sections 8 and 9.

See the prompt
You are a system design interviewer. Review my design for the interview problem below.

Problem: Design a Ride-Hailing App (like Uber)
Design a ride app that tracks drivers as they move, finds the drivers near a rider, and sends one of them to the rider.

What users must be able to do:
- Drivers broadcast GPS location every 4 seconds.
- Riders can request nearby available drivers within a 5km radius.
- Match rider with best available driver and track trip progress in real time.

How well it must work:
- Sub-second driver discovery latency.
- High availability for matching and trip lifecycle.
- Accurate geospatial proximity filtering.

Numbers to assume:
- 5 million active drivers each send their location every 4 seconds: 5,000,000 ÷ 4 = 1.25 million updates a second.

Judge my design at the Mid level.
A passing answer at this level: A complete design with numbers: about 1.25 million location updates a second and 100,000 search queries a second. It explains a geospatial index such as geohash and goes deep on one part, such as matching.

For each area below, say whether my design is strong, fine or weak. Give one reason and one fix for each:
1. Requirements and scope
2. Estimates
3. Core design
4. Deep dive
5. Failures and trade-offs

Then ask me the two follow-up questions an interviewer would ask next.
Do not write a full model answer for me.

My design:
[Describe your parts, how one request moves through them, and why you chose each one.]