# Serving Driver-partners Data at Scale Using Mirror Cache

[Grab](https://yomu.fyi/company/grab) · Indrajit Sarkar · Jan 26, 2021

**Type:** Problem & solution

## Summary

Grab's Drivers Data service handles up to 10,000 requests per second during peak hours to supply driver information across backend microservices. The original setup used MySQL with Redis and standalone in-memory local caches, but yielded a low 25% local cache hit rate due to traffic patterns characterized by high burst frequency for individual drivers alongside redundant database calls across nodes. To solve this, the team developed Mirror Cache, an in-memory caching system that pairs Dgraph's Ristretto library with an asynchronous gRPC replication layer to mirror updates across cluster nodes. The replicator batches updates within the same AWS availability zone and forwards data to single nodes across zones to minimize transfer overhead. Production deployment increased the in-memory cache hit rate to approximately 75% and reduced direct MySQL queries by 5%.

## Context

Grab's Drivers Data service experienced a low local cache hit rate (~25%) because different cluster nodes made redundant calls to Redis and MySQL for active driver data, driven by access patterns of high frequency in short time windows.

## Approach / What changed

The team replaced the standalone local cache with Mirror Cache, combining the Ristretto in-memory caching library with an asynchronous replicator that distributes cache updates across nodes via gRPC and handles cross-AZ propagation with minimal transfer overhead.

## Takeaways

- Mirror Cache increased the local in-memory cache hit rate from 25% to 75% during peak hours while reducing database calls by 5%.
- Cross-AZ network transfer overhead is reduced by sending batch cache updates to a single notifier node in another availability zone, which then distributes the batch to peer nodes in its zone.
- Because Mirror Cache data resides in volatile RAM, deployments wipe the cache and cause temporary load spikes on MySQL and Redis.

**Tags:** [Architecture](https://yomu.fyi/topic/architecture), [Caching](https://yomu.fyi/topic/caching), [gRPC](https://yomu.fyi/topic/grpc), [Performance](https://yomu.fyi/topic/performance), [Scalability](https://yomu.fyi/topic/scalability)

[Read original post](https://engineering.grab.com/mirror-cache-blog)
