Skip to content
Back to Cloud Services

AWS ElastiCache Redis/Memcached

Managed in-memory caching — Redis (cluster mode, HA, TLS) or Memcached, for sub-ms reads.

AWSIntermediate

Why

ElastiCache gives Redis/Memcached managed — patching, failover, backups. Sub-ms reads for hot data.

Redis cluster mode shards + replicates. Free tier: 750 hours t4g.micro.

When

Use for caching DB queries, session store, leaderboards, rate limiting. Avoid as primary store (no durability) or for cold data (use DB).

How

1. Create — aws elasticache create-cache-cluster --engine redis 2. Cluster mode — sharding + replicas, Multi-AZ failover 3. Security — security group, VPC only, TLS in-transit, KMS at-rest 4. Connect — redis-cli -h primary.xxxx.0001.use1.cache.amazonaws.com 5. Failover — automatic on node failure, 30-60s, app must reconnect 6. Backup — daily snapshot, restore to new cluster 7. Global Datastore — cross-region replication, <1s lag 8. Serverless — Redis Serverless, auto-scales, no capacity planning

Example

# Redis cluster with Multi-AZ aws elasticache create-replication-group \ --replication-group-id prod-redis \ --replication-group-description "prod cache" \ --engine redis --cache-node-type cache.t4g.micro \ --num-cache-clusters 2 \ --automatic-failover-enabled \ --multi-az-enabled \ --at-rest-encryption-enabled \ --transit-encryption-enabled // Node — ioredis with failover import Redis from "ioredis"; const redis = new Redis.Cluster( [{ host: "prod-redis.xxxx.use1.cache.amazonaws.com", port: 6379, tls: {} }], { redisOptions: { password: process.env.REDIS_AUTH, tls: {} } } ); await redis.setex("user:123", 300, JSON.stringify(user)); // 5min TTL

Common Problems

  • ⚠Memory exhaustion — set maxmemory-policy allkeys-lru, monitor used_memory
  • ⚠Failover 30-60s — app must handle reconnects, use ioredis Cluster for auto
  • ⚠TLS required for encryption — non-TLS clients fail, use stunnel or upgrade

Best Practices

  • ✓Use Redis Serverless — auto-scales, no capacity planning, pay per use
  • ✓Set LRU eviction — allkeys-lru, prevents OOM, evicts least used
  • ✓Use Global Datastore for multi-region — cross-region read replicas, <1s lag

FAQ

What is AWS ElastiCache Redis/Memcached and what problem does it solve?

Managed in-memory caching — Redis (cluster mode, HA, TLS) or Memcached, for sub-ms reads. It lets developers deploy, store, and scale without self-managing infrastructure — a core reference for cloud service selection.

How do I get started with AWS ElastiCache Redis/Memcached in 5 minutes?

Two steps to run it: (1) Create — aws elasticache create-cache-cluster --engine redis; (2) Cluster mode — sharding + replicas, Multi-AZ failover. Validate on the free tier first, then wire into production.

What is the #1 pitfall with AWS ElastiCache Redis/Memcached?

The most frequent issue is: Memory exhaustion — set maxmemory-policy allkeys-lru, monitor used_memory. Run a pre-launch checklist item by item, and add policy/config scanning in CI.

What are the best practices for AWS ElastiCache Redis/Memcached?

Best practices for AWS ElastiCache Redis/Memcached include: Use Redis Serverless — auto-scales, no capacity planning, pay per use; Set LRU eviction — allkeys-lru, prevents OOM, evicts least used; Use Global Datastore for multi-region — cross-region read replicas, <1s lag. The first one — "Use Redis Serverless — auto-scales, no capacity planning, pay per use" — should be a team default baked into your IaC templates.

How do I control cost and avoid bill surprises with AWS ElastiCache Redis/Memcached?

Three ways to prevent overspend: (1) tag every resource with env/team and enable billing alarms; (2) set budget thresholds to trigger Slack/email alerts; (3) review idle resources in Cost Explorer regularly and clean them up. Most AWS ElastiCache Redis/Memcached options offer a free tier — validate within free quota before scaling.