Skip to content
SD-25 · System design

Design a Surge Pricing

Asked at Staff level45 minutes
Our answers stay hidden until you reveal them.

Design the surge pricing system of a ride-hailing app. The city is split into small hexagonal cells. For every cell, the system keeps comparing how many riders want a car with how many free drivers are nearby, and sets a price multiplier, such as 1.4×, that applies to rides starting there. Riders see the multiplier in their price quote; drivers see a heat map of busy areas so they can move towards demand.

At the global peak there are about 1.44 million drivers online, each sending a location ping every 4 seconds, and about 40,000 price quotes a second: some 400,000 events a second in all. Demand can jump in two minutes when a concert ends, so a multiplier must be at most 60 seconds old. It must also be stable and fair: it should not flicker between 1.0× and 2.5× from one refresh to the next, a rider must pay the price they were quoted, and every multiplier ever shown must be explainable later to a regulator.

Good questions to ask first

Decide what you would assume for each before you look at ours.

  1. 1How fresh must a multiplier be?
  2. 2How big is a cell?
  3. 3What counts as demand?
  4. 4What counts as supply?
  5. 5Is the quoted price binding?
  6. 6Are there limits on the multiplier?
  7. 7Is it one global system?
  8. 8Do we need to explain past prices?

How to spend the 45 minutes

  1. 5minPart 1: Requirements and scope
  2. 5minPart 2: Estimates
  3. 5minPart 3: API
  4. 15minPart 4: Architecture, stage by stage
  5. 15minPart 5: Deep dives and trade-offs
Sketch your own design: boxes, arrows and the numbers that matter. Then compare it with ours.Break it in the labVisual walkthrough