Targeting Drivers for Real-Time Demand Spikes
Machine LearningModel answerLast updated
Build a system that selects which drivers to alert during sudden demand increases at high-traffic locations, balancing response speed with market stability.
You're building a notification system for a rideshare platform. When a high-demand location experiences a sudden supply shortage, the system must decide which drivers to contact and how many to reach out to.
Context:
- The platform operates in a large metropolitan area with thousands of active drivers
- Demand spikes occur multiple times daily at certain locations (airports, event venues, transit hubs)
- Each spike typically lasts 15-60 minutes
- Drivers receive location updates every few seconds
- Not all drivers respond to notifications, and some destinations are naturally more attractive than others
Your task: Describe how you would design a notification targeting system that determines:
- When to activate notifications for a location
- How many drivers should receive alerts
- Which specific drivers to contact
Address these specific questions:
- Why would a simple approach like "notify all drivers within X kilometers" create problems?
- Beyond travel time, what other signals would help predict whether a driver will respond?
- If you suspect nearby neighborhoods might also be experiencing shortages, how would you incorporate that into your decision?
- How would you measure whether your system is working correctly?
Discuss your modeling approach, feature choices, evaluation strategy, and potential failure modes.
Hints
Hint 1
Consider both the immediate shortage and second-order effects on nearby areas
Hint 2
Think about the difference between correlation and causation when measuring notification effectiveness
Hint 3
Travel time matters, but so does whether the driver would have gone there anyway
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Model Answer: Real-Time Driver Targeting System
Problem Reframing
The core objective isn't simply "send alerts to nearby drivers." The actual goal is:
Fill the location's supply gap within the demand window while minimizing marketplace disruption.
Disruption has multiple dimensions:
- Oversupply: Too many drivers arrive, prices drop rapidly, drivers feel misled
- Displacement: Removing drivers from areas that also need coverage
- Alert fatigue: Excessive notifications cause drivers to disable them or ignore future alerts
- Timing mismatch: Drivers arriving after demand normalizes gain nothing
This decomposition reveals three core problems:
- Detection: Identifying when intervention is needed
- Capacity planning: Determining the target notification count
- Selection: Ranking and choosing specific drivers
System Requirements
Key assumptions to establish upfront:
- Driver population: ~20,000 active drivers during peak hours in a major metro
- Location update frequency: Every 4 seconds, generating ~5,000 events/second
- Spike frequency: 5-30 occurrences per day per major location
- Response latency: System must decide and send within 5 seconds
- Constraints:
- Daily notification caps per driver (e.g., 3 maximum)
- Minimum cooldown between alerts (e.g., 30 minutes)
- Vehicle eligibility requirements for certain locations
- Physical capacity limits at destination
Why Simple Distance Rules Fail
A "notify all within X km" approach breaks down for several reasons:
Geographic naïveté: Straight-line distance ignores actual road networks. A river, highway barrier, or heavy traffic can make a nominally "close" driver take 3-4x longer than someone slightly farther away.
Status blindness: The rule treats all drivers identically:
- A driver currently on a trip, dropping off 2 minutes away, is an ideal candidate but gets excluded for being "busy"
- A driver about to end their shift and head home in the opposite direction will ignore the alert but gets included
No behavioral signal: Some drivers never accept certain trip types. Others were already heading to that location regardless. A distance rule can't distinguish these groups, producing zero marginal arrivals while burning notification budget.
Context ignorance: Pulling many drivers from a neighborhood that's itself experiencing high demand simply relocates the shortage.
Fixed magnitude: The same notification count goes out whether the gap is 5 drivers or 50, causing either insufficient coverage or severe overshooting.
Improvements: Use routed travel time instead of distance. Rank on incremental response probability multiplied by net value. Size the notification batch to the specific gap. Deploy in waves with real-time feedback. Penalize selection from supply-constrained origin areas.
Feature Engineering
Beyond travel time, these signals improve prediction:
Driver behavior history:
- Response rate to similar past alerts (overall and by time-of-day)
- Historical trip patterns to/from the target location
- General acceptance rate for trip requests
- Time elapsed since completing the last trip
Current driver state:
- Idle vs. on-trip (if on-trip: drop-off location and ETA)
- Current heading relative to target location
- Session duration (suggests fatigue or approaching shift end)
- Inferred home location direction
Notification history:
- Alerts received in past 24 hours
- Consecutive ignored alerts
- Previous opt-out incidents
Origin area context:
- Current supply-demand ratio in driver's zone
- Forecasted demand for next 30 minutes
- Local price multiplier
- Expected earnings-per-hour if driver remains in current area
Destination context:
- Queue or staging area congestion
- Predicted demand duration (using historical patterns + real-time signals like flight schedules)
- Current price multiplier and trend
Derived metrics:
- Probability that demand persists at driver's ETA
- Expected queue wait time upon arrival
- Net earnings: (destination value) - (origin opportunity cost)
Modeling Approach
Label definition: Driver arrives at target location within time window T and completes a relevant trip.
Critical insight: Use uplift modeling rather than simple response prediction. The question is not "will this driver respond?" but "will this driver respond because of the notification?"
Define uplift as:
uplift_i = P(arrive | notified, features_i) - P(arrive | not notified, features_i)
Training data generation: Maintain a 5-10% randomized holdout of eligible drivers who don't receive notifications. This provides unbiased counterfactual observations. Without this, you can't distinguish drivers who would have gone anyway from those the notification actually influenced.
Model architecture: Several options work:
- T-learner: Train separate models for treated and control groups, compute difference
- X-learner: Estimates individual treatment effects more efficiently for imbalanced groups
- Single model with treatment interaction: Include notification indicator and its interactions with key features
Gradient boosting (XGBoost, LightGBM) typically performs well given the mix of categorical and continuous features.
Scoring function:
value_i = uplift_i × (destination_value - origin_opportunity_cost_i)
This accounts for both response likelihood and market impact.
Calibration: Absolute probability calibration (isotonic regression or temperature scaling) is essential for capacity planning, not just rank ordering.
Capacity Planning and Delivery
Sizing the notification batch:
- Estimate current gap G from supply-demand forecasts
- Sort drivers by value_i (descending)
- Add drivers until sum of arrival probabilities Σ(p_arrive_i) covers G with 10-15% safety margin
- This relies on calibrated probabilities, not just relative scores
Multi-wave deployment:
- Wave 1: Send ~60% of target immediately
- Observation window: Monitor for 2-3 minutes—which drivers start moving toward location?
- Wave 2: Re-estimate remaining gap using observed responses, send additional drivers if needed
This feedback loop significantly reduces overshooting risk.
Supply protection: Apply caps on how many drivers to pull from each origin zone based on that zone's supply-demand ratio. Heavily constrained zones get lower caps or are excluded entirely.
Imbalance Detection
To determine when a region needs intervention:
Signal combination:
- Current supply count vs. demand (open requests + predictive app-open signals)
- Supply-demand trend over last 5-10 minutes
- Forecasted demand for next 15-30 minutes (incorporating external data: flight arrivals, event schedules, weather)
- Historical baseline for same location, day-of-week, and time-of-day
Trigger logic:
if (predicted_gap > threshold) AND
(trend_deteriorating) AND
(gap_duration_forecast > min_duration):
activate notification system
Thresholds should be location-specific. A 10-driver gap at a major airport is normal; the same gap at a smaller venue is critical.
Neighborhood spillover: Monitor adjacent zones simultaneously. If multiple neighboring areas show concurrent supply stress, the system should either reduce pull from those zones or increase notification scope beyond the immediate target.
Evaluation
Online metrics (A/B test new system vs. baseline):
Primary:
- Gap closure time (time to restore supply-demand balance)
- Rider wait time during spike
- Driver earnings for notified drivers vs. control
Secondary:
- Notification response rate
- Overshoot rate (supply exceeds demand after intervention)
- Origin zone disruption (surge events triggered in origin zones after driver departure)
Model-level metrics (offline):
- Uplift model: tau-risk or Qini coefficient on held-out test set with holdout observations
- Ranking quality: normalized discounted cumulative gain using actual arrivals
- Calibration: expected calibration error for arrival probabilities
Operational guardrails:
- Driver opt-out rate trends
- Alert fatigue indicators (declining response rate over time)
- Marketplace stability (price volatility after interventions)
Common failure modes to monitor:
-
Herding: All drivers arrive simultaneously, causing instant oversupply
- Mitigation: Wave-based sending with real-time gap updates
-
Notification spam: Same drivers receive excessive alerts
- Mitigation: Hard daily caps and cooldown periods
-
Origin zone collapse: Pulling too many drivers creates new shortage elsewhere
- Mitigation: Per-zone pull caps based on local supply stress
-
Model drift: Driver behavior changes, historical response patterns become stale
- Mitigation: Continuous model retraining (weekly or bi-weekly), monitoring response rate trends
-
Adverse selection: System learns to notify only highly responsive drivers, causing fatigue concentration
- Mitigation: Notification frequency caps prevent overuse of high-responders, forcing system to develop broader coverage
Architecture Sketch
- Streaming pipeline: Kafka → Flink for real-time feature aggregation → Redis feature store
- Demand forecasting: Short-horizon models per zone (15/30/45 min ahead)
- Trigger service: Evaluates imbalance conditions, emits notification events
- Candidate generation: Filters for eligible drivers within feasible travel time
- Ranking service: Loads features, scores with uplift model, applies value function
- Allocation optimizer: Selects drivers respecting constraints and origin-zone caps
- Notification gateway: Sends alerts, enforces fatigue rules, logs everything including randomized holdouts
- Feedback loop: Real-time monitoring triggers additional waves if needed
This design balances immediate response requirements with long-term marketplace health, using causal modeling to ensure notifications create actual value rather than just correlating with natural driver behavior.