KatInterview

Design a Real-Time Surge Pricing Engine for a Ride-Hailing Platform

Machine LearningModel answer
HardModel answerMachine Learningpricingmarketplacedemand-forecasting

Last updated

Design an end-to-end dynamic pricing system for a two-sided ride-hailing marketplace, balancing supply, demand, fairness, and service quality.

Scenario

A ride-hailing company operates a two-sided marketplace: riders request trips, drivers fulfill them. When demand spikes — a concert ends, it starts raining, morning rush begins — the system needs to respond with adjusted pricing that attracts more drivers, discourages low-priority rides, and keeps wait times acceptable. Do it too aggressively and you lose riders; too conservatively and ETAs balloon and drivers burn out on unproductive pickups.

You are asked to design the pricing engine that decides, in near real time, what multiplier to apply to the base fare across the city's geographic zones.

What to address

1. Data and features What signals would you feed the system? Cover real-time streams, historical baselines, and external context. What data must you log at quote time, and why does that matter later?

2. Modeling architecture Walk through the components you would build: demand forecasting, supply response, conversion/elasticity, ETA prediction, and how they connect to the final price decision. Where would you use gradient-boosted trees, where might reinforcement learning or bandits be appropriate, and what are the trade-offs?

3. Objective formulation How do you define what a good price is? What are you optimizing, and what does the objective miss? How do you weigh completed trips against revenue, driver pay, and rider experience?

4. Constraints and safety How do you prevent the multiplier from spiking to exploitative levels, flickering every few seconds, or treating different neighborhoods unequally? What operational guardrails does the system need?

5. Elasticity and causal identification Price both causes and correlates with demand. How do you actually measure how sensitive riders are to price changes in a way that is causally valid?

6. Validation and operations How do you test the system before it touches real riders? How do you run an experiment when prices in one zone affect adjacent zones? What do you monitor in production?

What a strong answer looks like

A strong answer separates prediction (what riders and drivers will do at a given price) from control (which price to actually set). It treats price as an intervention whose causal effect must be estimated, not just a label to predict. It names concrete model choices with honest trade-offs, states the objective clearly, and describes constraints as first-class requirements rather than afterthoughts.

Hints

Hint 1

Resist the urge to frame this as 'train a model that outputs the surge multiplier.' Price is an action with a causal effect on demand and supply — you need to estimate those effects separately before you can optimize over them. Think prediction layer, then control layer.

Hint 2

Ask yourself what happens at the extremes: multiplier too low means ETAs explode and drivers take long unproductive pickups; multiplier too high means idle drivers and riders who churn permanently. The optimal price clears the market near a target ETA. Making this concrete anchors your objective formulation.

Hint 3

Experimentation in a geographic marketplace violates standard A/B assumptions because control and treatment zones share the same pool of drivers. Name this interference problem explicitly and explain how holdout zone design or synthetic controls address it — interviewers consistently probe this.