GrabGao ChaoProblem & solution
How We Scaled Our Cache and Got a Good Night's Sleep
Summary
Growing business load on the Common Data Service (CDS) created potential bottlenecks for its single-threaded Redis cache on ElastiCache, necessitating horizontal scaling for greater capacity and throughput. After ruling out master-slave replication and intermediate Twemproxy setups due to memory constraints and proxy I/O bottlenecks, the team implemented client-side sharding. Using an internal Go package for consistent hashing, CDS instances hash cache keys locally to determine the target shard. The implementation encapsulates hashing inside a thin `ShardedCache` wrapper sharing the original cache interface while supporting Ketama and custom hash functions. Deploying via double-writing cron jobs during off-peak hours reduced database read pressure and improved P99 latency.
Context
As business growth increased cache traffic, the Common Data Service's single-threaded Redis setup on ElastiCache risked becoming a bottleneck and lacked sufficient memory space for future caching needs.
Approach / What changed
Implemented client-side custom sharding using an internal Go consistent hashing package, wrapping the original cache interface in a `ShardedCache` layer with Ketama hashing, and deployed using double-writing cron jobs during off-peak hours.
Takeaways
Master-slave Redis replication failed to solve memory space limitations, while Twemproxy was rejected because it introduces an I/O bottleneck under heavy load.
The `ShardedCache` was implemented in Go as a thin wrapper embedding the standard `Cache` interface to enable seamless implementation swapping and custom hashing injection.
A two-day migration strategy utilized off-peak deployment alongside double-writing cron jobs to warm up the new shards and prevent database query spikes.
Source and freshness
- Source
- engineering.grab.com
- Published
- Added to Yomu
- Last updated
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.