# Recipe for Building a Widget: How We Helped to “Peak-Shift” Demand by Helping Passengers Understand Travel Trends

[Grab](https://yomu.fyi/company/grab) · Lara PuReum Yim · Mar 7, 2019

**Type:** Problem & solution

## Summary

Transport demand spikes during regular commuting hours often outpace driver availability, resulting in passenger wait times and fare surges. To mitigate these imbalances, Grab created the Travel Trends Widget for its mobile feed to redistribute ride requests toward off-peak windows. The widget uses machine learning forecasting to present historical supply-demand patterns alongside pricing trends for the upcoming two hours. To handle anticipated high query rates across millions of database entries, engineers periodically load precomputed trend data into an in-memory data structure rather than querying the database per request. The feature rolled out to feeds in Singapore and Jakarta within four weeks of initial development.

## Context

Transport demand spikes during regular commuting hours cause ride requests to outpace driver availability, increasing passenger wait times and fare surge imbalances.

## Approach / What changed

Grab built a Travel Trends Widget for its mobile feed using machine learning to forecast two-hour pricing trends, presented with behavioural science nudges and powered by an in-memory data store for high-throughput API serving.

## Takeaways

- Surge patterns exhibit daily seasonality, showing distinct hourly surge dynamics between different days of the week rather than uniform peak hours.
- To maintain low latency under high QPS, backend engineers periodically stored aggregated trend data in an in-memory structure rather than querying the database directly on each API call.
- Designers selected tapping as the primary interaction method for individual time bars to avoid conflicting with existing feed scrolling and scrubbing gestures.

**Tags:** [Caching](https://yomu.fyi/topic/caching), [Machine Learning](https://yomu.fyi/topic/machine-learning), [Performance](https://yomu.fyi/topic/performance), [Scalability](https://yomu.fyi/topic/scalability)

[Read original post](https://engineering.grab.com/peak-shift-demand-travel-trends)
