Marketplace

Real-time Surge / Dynamic Pricing

Compute geo-zone pricing multipliers in seconds based on local supply-demand imbalance.

Scale to anchor on

Thousands of cities, tens of thousands of geo-zones updated every 10–60 seconds, latency from signal to user < 1 minute.

Requirements

Functional

  • Compute and publish multipliers per zone.
  • Smooth changes to avoid jarring user experience.
  • Respect regulatory caps where applicable.
  • Expose price to riders before they commit.

Non-functional

  • Latency from signal change to user-visible price < 1 minute.
  • Resilience to bad data (manual override required).
  • Audit trail for regulatory review.

High-level architecture

Streams of demand (open requests) and supply (active drivers per zone) feed a pricing model per H3 cell. The model emits multipliers smoothed by exponential moving average and capped by policy. The current price snapshot is cached at the edge for quote-time reads.

Components

Supply/demand stream
Real-time aggregation per cell.
Pricing model service
Computes raw multipliers per cell.
Smoothing + policy layer
Applies EMA, caps, and overrides.
Price cache
Low-latency price snapshot served at quote time.
Audit log
Append-only history for regulator review.

Key decisions

Aggregate by H3 cell.
Cells are uniform-sized and support neighbor queries; cleaner than rectangles or city polygons.
Smoothing layer separate from model.
Policy changes (caps, ramps) shouldn't require model retraining.
Snapshot cache for quote-time reads.
Quotes are very high QPS; reading from the streaming pipeline is too expensive and too volatile.
Audit log of every decision.
Regulatory reality demands it; also essential for post-incident analysis.

Pitfalls

  • No smoothing: prices jitter and erode user trust.
  • Single global model that ignores city-level differences.
  • No override mechanism for bad data or incidents.
  • Forgetting the rider experience — prices changing between quote and confirmation are an unrecoverable trust failure.

Follow-up questions

  • How do you smooth multipliers without losing responsiveness?
  • What's the audit trail for a regulator inquiry?
  • How do you handle a city-wide outage in supply data?
  • How do you enforce regulatory caps?

Related patterns

Further reading