Design a Dynamic Pricing Engine

System Design
Hard
Uber
32.9K views

Design a service that uses machine learning models to dynamically set prices for products (e.g., flight tickets, ride-hailing). Focus on model deployment and A/B testing price points.

Why Interviewers Ask This

Interviewers at Uber ask this to evaluate your ability to balance complex algorithmic logic with real-world business constraints. They specifically test your understanding of how machine learning models integrate into high-throughput systems, your awareness of the risks associated with price volatility, and your strategy for validating model performance through rigorous A/B testing before full deployment.

How to Answer This Question

1. Clarify requirements by defining scope: Are we pricing rides globally or a specific city? Define latency constraints (e.g., sub-200ms response) and data freshness needs. 2. Outline the data pipeline: Detail how you ingest real-time supply/demand signals, historical traffic patterns, and external factors like weather or events. 3. Design the core architecture: Propose a microservices approach where a feature store feeds a pre-trained ML model, ensuring the inference engine scales horizontally during peak hours. 4. Address safety and fairness: Discuss guardrails to prevent price gouging and ensure driver earnings remain viable. 5. Explain validation: Describe an A/B testing framework using multi-armed bandits to safely roll out new price points to small user segments before global release.

Key Points to Cover

  • Explicitly addressing latency constraints critical for ride-hailing contexts
  • Describing a concrete data ingestion pipeline using streaming technologies
  • Integrating business guardrails to prevent algorithmic bias or price shocks
  • Proposing a sophisticated A/B testing strategy like Multi-Armed Bandits
  • Defining clear success metrics beyond just revenue, including conversion and retention

Sample Answer

To design a dynamic pricing engine for Uber, I would start by clarifying that the system must handle millions of requests per second with sub-second latency while ensuring revenue optimization without alienating users. First, the data layer would aggregate real-time inputs: current driver supply, rider demand heatmaps, traffic congestion, and local events via a Kafka stream. These features feed into a Feature Store for low-latency retrieval. The core inference service would host a gradient boosting model, likely XGBoost, trained on historical trip completion rates and elasticity curves. Crucially, this isn't just raw prediction; we need a policy layer that applies business rules, such as capping surge multipliers during emergencies or ensuring minimum driver payouts. For deployment, I would implement a canary release strategy. We wouldn't roll out the new model to all users immediately. Instead, we'd use a Multi-Armed Bandit algorithm to dynamically route traffic, exposing 5% of users to the new pricing logic. We'd monitor key metrics like booking conversion rate, average order value, and customer cancellation rate. If the new model improves revenue without dropping conversion below a threshold, we gradually increase the traffic split. This iterative approach minimizes risk while allowing us to validate the model's impact on both riders and drivers in a live environment.

Common Mistakes to Avoid

  • Focusing solely on the ML algorithm while ignoring the engineering infrastructure required for real-time inference
  • Neglecting to discuss how to handle edge cases like sudden demand spikes or network failures
  • Overlooking the importance of A/B testing and suggesting a direct, risky full-scale rollout
  • Ignoring the human element by failing to mention driver incentives or rider satisfaction safeguards

Practice This Question with AI

Answer this question orally or via text and get instant AI-powered feedback on your response quality, structure, and delivery.

Start Practicing

Related Interview Questions

Browse all 150 System Design questionsBrowse all 57 Uber questions