The Problem: Geography and Gravity
Speed of light is a hard limit. A TCP round trip between Virginia (us-east-1) and London (eu-west-2) takes approximately 80ms. For a cache that normally responds in 0.3ms, routing European users to a US cache cluster eliminates most of the latency benefit. Additionally, if us-east-1 experiences an outage, any application that depends solely on that region's cache loses its caching layer entirely.
The Solution: Global Datastore
Global Datastore is ElastiCache's mechanism for replicating a Redis cluster across AWS regions. It creates a single logical cache with geographically distributed nodes.
Architecture:
- Primary Cluster (Active/Active for Writes): One region is designated as the write primary. It accepts both reads and writes. Example:
us-east-1. - Secondary Clusters (Read-Only): One or more additional regions hold read-only replicas. Data is asynchronously replicated from the Primary. Example:
eu-west-2(London),ap-northeast-1(Tokyo).
Key Behaviors:
- Local Reads: A user in London reads from the London secondary cluster. Latency: sub-millisecond (same-region). The 80ms cross-Atlantic round trip is eliminated.
- Asynchronous Replication: Writes to the Primary are propagated to secondaries with a typical replication lag of under 1 second under normal conditions. This means secondaries may serve slightly stale data — a trade-off you must accept.
- Disaster Recovery (Failover): If the Primary region fails, you can manually promote a secondary cluster to become the new Primary. This is a deliberate manual action (not automatic) to prevent split-brain scenarios. Typical promotion time is under 1 minute.
- Cross-Region Replication Cost: AWS charges for data transfer between regions. Factor this into cost modeling for write-heavy workloads.
When to Use Global Datastore:
- Applications with users in multiple geographic regions who need low-latency cache reads.
- Disaster recovery architectures requiring a warm cache in a secondary region (avoids cold-start cache miss storms after failover).
- Compliance requirements mandating data residency in specific regions (note: data IS replicated across regions, so this may conflict with strict data residency requirements).