Monitoring Amazon ElastiCache across AWS Regions with Amazon CloudWatch for active-active architectures
This article shows how to set up Amazon CloudWatch to monitor ElastiCache across Regions. It follows the AWS Well-Architected Reliability Pillar, the ElastiCache Well-Architected Lens, and the Disaster Recovery of Workloads on AWS whitepaper.
Introduction
Many multi-Region applications use Amazon ElastiCache (Valkey or Redis OSS) to serve low-latency reads close to users in each Region. If you run an active-active, multi-site disaster recovery (DR) strategy, monitoring is part of the recovery mechanism, not an extra. Your alarms drive the decision to move traffic away from an impaired Region, and that decision has to work even when a Region is degraded.
What "active-active" means for ElastiCache
Before you design monitoring, decide which multi-Region pattern you use. The pattern determines which signals matter.
| Pattern A: Global Datastore (read-local, write-global) | Pattern B: Independent Regional caches (read-local, write-local) | |
|---|---|---|
| How it works | One primary cluster accepts writes. Up to two secondary clusters in other Regions receive asynchronous replication and serve local reads. | Each Region has its own cache cluster in front of a database that accepts writes in multiple Regions, such as Amazon DynamoDB global tables. Caches are filled and invalidated locally. |
| Active-active scope | Reads are active in all Regions. Writes go to one Region. | Reads and writes are active in all Regions. |
| Regional failover | Promote a secondary cluster to primary. ElastiCache doesn't fail over between Regions automatically. | Shift traffic away from the impaired Region. No cache promotion is needed. |
| Key cross-Region signal | GlobalDatastoreReplicationLag | Health of each Regional stack, cache hit rate after a traffic shift, and database replication health |
Both patterns are valid. Pattern A gives you a warm, replicated cache in the standby Region. Pattern B removes the cache from the failover path entirely. The monitoring steps below cover both and note where they differ.
Resilience principles applied
- Regional independence. Each Region monitors itself with alarms that live in that Region, so losing one Region doesn't blind the other.
- Outside-in monitoring. Each Region also checks the other Region's user-facing health. An impaired Region may not be able to report its own failure.
- Data plane over control plane during recovery. Make failover decisions with mechanisms that rely on data-plane operations, such as Amazon Route 53 Application Recovery Controller (ARC) routing controls. Keep control-plane operations, such as promoting a Global Datastore secondary, pre-tested and scripted.
- Static stability. Pre-provision capacity in every Region so a failover doesn't depend on scaling up during an event.
- Practice. Test failover regularly, and confirm that alarms fire and runbooks work.
Prerequisites
- ElastiCache node-based clusters running Valkey 7.2 or later, or Redis OSS 5.0.6 or later, with Multi-AZ and automatic failover enabled in each Region.
- For Pattern A, a Global Datastore with a primary and one or two secondary Regions. All clusters must be in the same AWS account. See Prerequisites and limitations.
- An Amazon SNS topic for alarm notifications in each Region.
- If your monitoring spans multiple accounts, AWS Organizations, which is recommended for cross-account CloudWatch features.
Limitation: Global Datastore doesn't support cross-account deployments. The primary and all secondary clusters must be in the same AWS account. If your multi-account strategy places each Region in a separate account, use Pattern B (independent Regional caches), or keep the cache tier in one shared account. Cross-account monitoring (Step 6) still works either way.
The examples use us-east-1 (Region A) and us-west-2 (Region B). Replace resource names with your own.
Architecture overview
Figure 1. Each Region monitors itself with Regional and composite alarms, and probes the peer Region with a CloudWatch Synthetics canary. Route 53 ARC routing controls shift user traffic. The cross-Region dashboard is for visibility and is not part of the failover decision path.
Step 1: Configure Regional telemetry and notifications
In each Region:
- Confirm that ElastiCache publishes metrics to the
AWS/ElastiCachenamespace. This happens automatically, at no extra charge. - Set an SNS notification topic on each Regional cluster to receive ElastiCache events, such as failovers and maintenance. You can set it per secondary cluster when you add the cluster to the Global Datastore.
- Optionally, deliver the slow log and engine log to Amazon CloudWatch Logs for troubleshooting.
- For node-based Valkey clusters, consider OpenTelemetry metrics and ElastiCache Insights. Insights is a pre-built CloudWatch dashboard for cluster health.
Step 2: Create Regional health alarms (both patterns)
Create these alarms in the same Region as the cluster. CloudWatch metric alarms evaluate metrics from the Region they are created in. Use them to detect impairment of the Regional cache itself.
| Metric | Why it matters | Example starting threshold |
|---|---|---|
EngineCPUUtilization | The engine thread is saturated. For nodes with 4 or more vCPUs, set your threshold on this metric. For nodes with 2 or fewer vCPUs (including many .large types supported by Global Datastore), also alarm on CPUUtilization, because ElastiCache background processes can use a significant share of the host's CPU. | > 80% for 5 minutes |
DatabaseMemoryUsagePercentage | Memory pressure leads to evictions. | > 80% |
Evictions | Keys are being dropped under memory pressure. | Sustained above your baseline |
CurrConnections | Connection storms or leaks. | Well above your baseline |
ReplicationLag | Lag between replicas and the primary within the Region. | > 1 second, sustained |
SuccessfulReadRequestLatency / SuccessfulWriteRequestLatency (p99) | Latency your users feel. | Based on your SLO |
ErrorCount | Failed commands. | > 0, sustained |
CacheHitRate | Efficiency. After a traffic shift in Pattern B, a drop shows the cache is cold. | < 0.8 |
Example (Region B, primary node of a cluster):
aws cloudwatch put-metric-alarm \ --region us-west-2 \ --alarm-name "ec-usw2-engine-cpu-high" \ --namespace AWS/ElastiCache \ --metric-name EngineCPUUtilization \ --dimensions Name=CacheClusterId,Value=my-cache-usw2-0001-001 \ --statistic Average --period 60 \ --evaluation-periods 5 --datapoints-to-alarm 5 \ --threshold 80 --comparison-operator GreaterThanThreshold \ --treat-missing-data missing \ --alarm-actions arn:aws:sns:us-west-2:111122223333:ops-alerts
Metrics are emitted per node, so create alarms for each node, or at least for each shard primary. Use infrastructure as code (Step 8) to keep this manageable.
Step 3: Monitor cross-Region replication (Pattern A)
GlobalDatastoreReplicationLag is the lag, in seconds, between the secondary Region's primary node and the primary Region's primary node. With cluster mode enabled, it reports the maximum lag across shards. It is published in the secondary Region, so create the alarm there.
aws cloudwatch put-metric-alarm \ --region us-west-2 \ --alarm-name "ec-global-replication-lag-high" \ --namespace AWS/ElastiCache \ --metric-name GlobalDatastoreReplicationLag \ --dimensions Name=CacheClusterId,Value=my-cache-usw2-0001-001 \ --statistic Maximum --period 60 \ --evaluation-periods 5 --datapoints-to-alarm 3 \ --threshold 5 --comparison-operator GreaterThanThreshold \ --treat-missing-data breaching \ --alarm-actions arn:aws:sns:us-west-2:111122223333:ops-alerts
- The 5-second threshold is an example. Typical replication lag between Regions is under one second, so set the threshold above your observed baseline (to avoid alarms on brief spikes) and below your recovery point objective (RPO). For example, with a 30-second RPO you might alarm at 5–10 seconds sustained, which leaves time to act before you exceed it. Review a few weeks of
GlobalDatastoreReplicationLag(p99 and maximum) to set your baseline. Sustained lag tells you how much data you could lose if you promote now. --treat-missing-data breachingtreats a missing metric as a problem, which can happen when the primary Region is impaired. Expect this alarm to fire during planned promotions, and document that in your runbook.- After a promotion the roles swap, so the lag metric is published in the other Region. Deploy this alarm in every Region that can be a secondary.
Step 4: Add outside-in monitoring from the peer Region (both patterns)
Regional alarms tell you whether the cache is healthy. They don't tell you whether users can reach the application. Run an Amazon CloudWatch Synthetics canary in Region B that probes Region A's endpoint, and the reverse.
- Point the canary at a health endpoint that exercises a cache read, and for Pattern A in the primary Region, a write. That way the check covers the whole path, not just the load balancer.
- Alarm on the canary's
SuccessPercentmetric in the Region where the canary runs. - Because the canary runs in the peer Region, it keeps reporting even if the monitored Region can't publish its own metrics.
Step 5: Combine signals with composite alarms
Single metrics are noisy. Use composite alarms in each Region to roll the signals up into one "Region health" alarm. Composite alarms combine alarms from the same Region.
aws cloudwatch put-composite-alarm \ --region us-west-2 \ --alarm-name "region-use1-impaired-as-seen-from-usw2" \ --alarm-rule 'ALARM("canary-use1-success-low") AND (ALARM("ec-global-replication-lag-high") OR ALARM("canary-use1-latency-high"))' \ --alarm-actions arn:aws:sns:us-west-2:111122223333:dr-decision
This alarm requires both a user-facing symptom and a supporting signal before it pages the DR decision-makers, which cuts down on false failovers.
Step 6: Build a cross-Region dashboard for one view
Use the cross-account cross-Region CloudWatch console to build one dashboard that shows both Regions side by side. Each metric can set its own region, and its own accountId when you use cross-account sharing:
{ "widgets": [ { "type": "metric", "width": 12, "height": 6, "properties": { "title": "Global Datastore replication lag (s)", "region": "us-east-1", "stat": "Maximum", "period": 60, "metrics": [ ["AWS/ElastiCache", "GlobalDatastoreReplicationLag", "CacheClusterId", "my-cache-usw2-0001-001", { "region": "us-west-2", "accountId": "111122223333", "label": "us-west-2 secondary" }] ] } }, { "type": "metric", "width": 12, "height": 6, "properties": { "title": "Engine CPU by Region (%)", "region": "us-east-1", "stat": "Average", "period": 60, "metrics": [ ["AWS/ElastiCache", "EngineCPUUtilization", "CacheClusterId", "my-cache-use1-0001-001", { "region": "us-east-1", "accountId": "111122223333", "label": "us-east-1" }], ["AWS/ElastiCache", "EngineCPUUtilization", "CacheClusterId", "my-cache-usw2-0001-001", { "region": "us-west-2", "accountId": "111122223333", "label": "us-west-2" }] ] } }, { "type": "alarm", "width": 24, "height": 4, "properties": { "title": "Region health", "alarms": [ "arn:aws:cloudwatch:us-east-1:111122223333:alarm:region-usw2-impaired-as-seen-from-use1", "arn:aws:cloudwatch:us-west-2:111122223333:alarm:region-use1-impaired-as-seen-from-usw2" ] } } ] }
Add accountId when the dashboard lives in a central monitoring account, as in this example, where the workload account 111122223333 holds the clusters. The workload account must share CloudWatch data with the monitoring account. Because Global Datastore keeps all clusters in one account, every ElastiCache metric uses the same accountId. Omit the field if the dashboard is in the workload account.
Use the dashboard for awareness and investigation, not as the trigger for failover. Keep the decision-making alarms in each Region, and keep the dashboard definition in source control.
If you centralize telemetry across many accounts, review cross-account cross-Region metrics centralization. Check which metric types it supports before you rely on it for ElastiCache metrics. Don't place a centralized account or Region in your failover decision path.
Step 7: Connect alarms to the failover decision and runbook
-
Traffic shift. Use Route 53 ARC routing controls to move users between Regions. Routing control state changes use the ARC data plane, which runs across five Regions, so they're designed to work during a Regional impairment. Decide in advance whether the composite alarm pages a human (most common for Regional failover) or triggers automation.
-
Promote the cache (Pattern A only). After traffic moves, promote the secondary cluster so it accepts writes:
aws elasticache failover-global-replication-group \ --region us-west-2 \ --global-replication-group-id <global-datastore-id> \ --primary-region us-west-2 \ --primary-replication-group-id my-cache-usw2During promotion the Global Datastore enters a Modifying state. Applications must then send writes to the new primary endpoint. Store Regional endpoints in configuration your application can switch without a deployment, such as AWS Systems Manager Parameter Store or AWS AppConfig in each Region.
-
Pattern B. No cache action is needed. Watch
CacheHitRate,EngineCPUUtilization, andCurrConnectionsin the surviving Region as it absorbs the extra traffic. Static stability means that Region should already have the capacity. -
Failback. After the impaired Region recovers, confirm that replication lag is back to normal before you move the primary or traffic back.
For an automated, tested example of Global Datastore failover and failback with AWS Step Functions, see Automate cross-Region failover and failback by using DR Orchestrator Framework.
Step 8: Deploy monitoring as code in every Region
Monitoring has to be identical in every Region, because any Region can become primary. Define alarms, canaries, and composite alarms in AWS CloudFormation or AWS CDK, and deploy them to all Regions with CloudFormation StackSets. The Global Datastore itself can be defined with AWS::ElastiCache::GlobalReplicationGroup.
Step 9: Test regularly
- Run planned Regional failover game days: shift traffic, promote the secondary (Pattern A), and confirm alarms, dashboards, and runbooks behave as expected.
- Use AWS Fault Injection Service to test Availability Zone-level resilience of ElastiCache and your application.
- Measure your actual recovery time and data loss against your recovery time objective (RTO) and RPO, then adjust thresholds.
Common pitfalls
- Assuming Global Datastore accepts writes in multiple Regions. Secondary clusters are read-only until promoted.
- Alarms only in the primary Region. After a promotion, or during a Regional event, you lose visibility. Deploy everything everywhere.
- Relying on a central dashboard or account to trigger failover. That creates a dependency on a single Region.
- Skipping the endpoint switch after promotion. Your application must send writes to the new primary.
- Cold caches after a traffic shift (Pattern B). Pre-warm caches, or size the database to absorb extra cache misses.
Summary
For an active-active design with ElastiCache, put alarms in each Region and keep them independent. Add outside-in canaries from the peer Region, and roll the signals up with composite alarms so you get a clear Region-health signal. Use the cross-Region dashboard for visibility, and make failover decisions with data-plane mechanisms such as Route 53 ARC. Treat Global Datastore promotion as a rehearsed, scripted step, and deploy monitoring identically to every Region.
References
- Replication across AWS Regions using global datastores
- Metrics for Valkey and Redis OSS
- ElastiCache Well-Architected Lens: Reliability Pillar
- Monitor across accounts and Regions (CloudWatch)
- Cross-account cross-Region CloudWatch console
- Disaster Recovery of Workloads on AWS (whitepaper)
- Well-Architected Reliability Pillar: Plan for disaster recovery
- Designing and implementing logging and monitoring with Amazon CloudWatch
- Guidance for Cross-Region Failover and Graceful Failback on AWS
Relevant content
AWS OFFICIALUpdated 3 months agoasked 4 years ago
AWS OFFICIALUpdated 2 years ago