# How Grab built a scalable, high-performance ad server

[Grab](https://yomu.fyi/company/grab) · Anthony McCallum · Feb 11, 2022

**Type:** Problem & solution

## Summary

Grab transitioned from an off-the-shelf MVP to an in-house ad serving system to accommodate business scale, hyperlocal requirements, and machine learning personalization. The architecture orchestrates core microservices and data pipelines across sequential steps: targeting, capping, pacing, scoring, ranking, pricing, and tracking. ElasticSearch serves as the targeting ads repository, while ScyllaDB acts as the high-throughput stats store fed by Kafka streams and data pipelines. The system operates on key engineering principles including parallelization and tuned latency limits, graceful fallbacks for slow dependency calls, and a unified server serving all ad types across the superapp.

## Context

An off-the-shelf MVP proved the ads business model, but Grab needed an in-house platform to integrate with its superapp ecosystem, support exponential scale, handle hyperlocal user experiences, and incorporate machine-learning-driven personalization.

## Approach / What changed

Grab built microservices, streams, and pipelines that execute a multistep ad serving flow utilizing ElasticSearch for ad targeting, ScyllaDB for capping and pacing stats, and Kafka data pipelines to capture tracking events.

## Takeaways

- ElasticSearch serves as the ad repository to query candidate ads across diverse targeting criteria like search keywords, location, and user preferences.
- Kafka event streams feed impression, click, and purchase data back into ScyllaDB to enforce real-time campaign budget caps and pacing limits.
- To protect user-facing latency against slow dependency calls, the ad server relies on strict timeouts and falls back to non-personalized results instead of dropping the ad.

**Tags:** [Architecture](https://yomu.fyi/topic/architecture), [Elasticsearch](https://yomu.fyi/topic/elasticsearch), [Kafka](https://yomu.fyi/topic/kafka), [Microservices](https://yomu.fyi/topic/microservices), [Scalability](https://yomu.fyi/topic/scalability)

[Read original post](https://engineering.grab.com/scalable-ads-server)
