← Back to All Questions
Very Hard~55 minAnalytics

Design Surge Pricing System

UberLyftDoorDashAirbnbAmazon

📝 Problem Description

Design a dynamic pricing system like Uber's surge pricing. Adjust prices in real-time based on supply (drivers) and demand (riders). Balance market efficiency with fairness. Handle geographic pricing zones.

👤 Use Cases

1.
System wants to detects high demand so that increases prices in zone
2.
Rider wants to requests ride so that sees current surge multiplier
3.
Driver wants to sees high surge so that moves to high-demand area
4.
System wants to supply increases so that surge decreases

✅ Functional Requirements

  • Calculate surge multiplier per zone
  • Update prices in real-time (< 1 min)
  • Show surge to riders before booking
  • Apply surge to ride fare
  • Historical surge data for analysis

⚡ Non-Functional Requirements

  • Price update latency < 30 seconds
  • Handle 100K price requests/sec
  • No stale prices (max 1 min old)
  • Geographic granularity (1km² zones)

⚠️ Constraints & Assumptions

  • Surge must respond to real-time conditions
  • Cannot change price after ride accepted
  • Regulatory limits on max surge

📊 Capacity Estimation

👥 Users
10M daily riders, 1M drivers
💾 Storage
10GB (supply/demand data)
⚡ QPS
Price requests: 100K/sec, Supply updates: 10K/sec
📐 Assumptions
  • 10M ride requests per day (~120/sec)
  • 10K geographic zones per city
  • Supply/demand recalculated every 30 seconds
  • Price queries: 100K/sec peak
  • 1M active drivers with location updates every 5s
  • Surge multiplier range: 1.0x to 5.0x

💡 Key Concepts

CRITICAL
Geographic Zones
Divide city into hexagonal zones (H3) for granular pricing.
CRITICAL
Supply/Demand Ratio
surge = f(demand / supply), with smoothing.
HIGH
Price Smoothing
Avoid rapid price changes with exponential moving average.
MEDIUM
Demand Prediction
ML model predicts surge to pre-position drivers.

💡 Interview Tips

  • 💡Start with the supply/demand imbalance problem
  • 💡Discuss the ethical considerations of surge pricing
  • 💡Emphasize real-time data processing requirements
  • 💡Be prepared to discuss regulatory compliance
  • 💡Know the tradeoffs between accuracy and simplicity
  • 💡Understand how Uber/Lyft approach this problem