# Migrating Existing Datastores

[Grab](https://yomu.fyi/company/grab) · Nishant Gupta · Aug 8, 2017

**Type:** Problem & solution

## Summary

Grab's Identity team faced imminent memory exhaustion on a single Redis node used to cache mobile authentication tokens under rapid user growth. Because read traffic outweighed write traffic by roughly 200 times, the team opted for an AWS ElastiCache cluster with three shards and two read replicas per shard. They executed a zero-downtime, six-phase migration plan while handling a peak load of 20,000 queries per second. The migration transitioned through initial one-time data replication, asynchronous shadow writes, synchronous dual writes, asynchronous read validation, switching primary reads, and final write cleanup. Controlled by feature flags and monitored with metrics at every stage, the migration completed without invalidating tokens or causing service disruptions.

## Context

Rapid user growth at Grab threatened to exhaust memory on a single Redis node caching authentication tokens within two months, while single-node failure risks and write impacts during replica promotions made high availability critical.

## Approach / What changed

Migrated from the single Redis instance to a 9-node AWS ElastiCache cluster (3 shards with 2 read replicas each) using a flag-controlled, six-step rollout featuring initial data migration via SCAN, DUMP, and RESTORE, followed by dual writing and asynchronous read validation.

## Takeaways

- Peak authentication read load exceeded write load by approximately 200 times, making horizontal read scalability via ElastiCache replicas more critical than dynamic write resharding.
- Initial data migration between Redis instances was executed without impacting live performance by combining the SCAN, DUMP, and RESTORE commands.
- Zero-downtime cutover was ensured by gating each phase—from shadow async writes to dual sync writes and comparative async read validations—behind dynamic configuration flags backed by extensive metrics.

**Tags:** [Authentication](https://yomu.fyi/topic/authentication), [AWS](https://yomu.fyi/topic/aws), [Caching](https://yomu.fyi/topic/caching), [Migrations](https://yomu.fyi/topic/migration), [Redis](https://yomu.fyi/topic/redis)

[Read original post](https://engineering.grab.com/migrating-existing-datastores)
