Updated: 2023-09-01
4 min read


Amazon Elasticache is a fully managed Redis or Memcached in-memory data store.

It’s great for use cases like two-tier web applications where the most frequently accesses data is stored in ElastiCache so response time is optimal.

You can use ElastiCache for caching, which accelerates application and database performance, or as a primary data store for use cases that don’t require durability like session stores, gaming leaderboards, streaming, and analytics.

Compatible with Redis and Memcached


Current price

Use Cases

Type: In-memory

Use CaseBenefit
Web session storeIn cases with load-balanced web servers, store web session information in Redis so if a server is lost, the session info is not lost, and another web server can pick it up
Database cachingUse Memcached in front of AWS RDS to cache popular queries to offload work from RDS and return results faster to users
LeaderboardsUse Redis to provide a live leaderboard for millions of users of your mobile app
Streaming data dashboardsProvide a landing spot for streaming sensor data on the factory floor, providing live real-time dashboard displays

Caching Engines

Simple, no-frillsYou need encryption
You need to elasticity (scale out and in)You need HIPAA compliance
You need to run multiple CPU cores and threadsSupport for clustering
You need to cache objects (e.g. database queries)You need complex data types
You need HA (replicationBackup and restore features
Pub/Sub capabilityMulti-AZ with Auto-Failover
Non persistent. No backups
Multi-node for partitioning of data (sharding)


ElastiCache manages Memcached nodes as a pool that can grow and shrink (similar to an EC2 Auto Scaling group); individual nodes are expendable and non-persistent.

Memcached provides a simple caching solution that best supports object caching and lets you scale out horizontally. Ideal for offloading a DB’s contents into a cache.


ElastiCache manages Redis more as a relational database, i.e. Redis clusters are managed as persistent, stateful entities that include using multi-AZ redundancy for handling failover (similar to RDS).

Redis supports complex data structures, hence would be ideal in cases where sorting and ranking datasets in memory are important (e.g. such as in leaderboards for games).

Caching Strategies

Lazy Loading

  • The data that is read from the DB is stored in the cache. The data can become stale
  • The data becomes stale because there are no updates to the cache when data is changed in the database

Only cache data when it is requested. Cache miss penalty on initial request. Chance to produce stale data; can be mitigated by setting a TTL. Shorter TTL = less stale data.


  • The data is added/updated into the cache everytime the data is written to the DB (no stale data)
  • Because the data in the cache is updated every time it’s written to the database, the data in the cache is always current.

Every database write will write to the cache as well. Data is never stale however there will be alot more operations to perform; and these resources are wasted if most of the data is never used.

Session Store

  • Stores temporary session data in cache (with TTL) - Time to Live. Data expires after the given time


Configuring a Lambda function to access Amazon ElastiCache in an Amazon VPC



What is one reason that AWS does not recommend that you configure your ElastiCache so that it can be accessed from outside AWS?

  1. The metrics reported by CloudWatch are more difficult to report.
  2. Security concerns and network latency over the public internet.
  3. The ElastiCache cluster becomes more prone to failures.
  4. The performance of the ElastiCache cluster is no longer controllable.

Elasticache is a service designed to be used internally to your VPC. External access is discouraged due to the latency of Internet traffic and security concerns. However, if external access to Elasticache is required for test or development purposes, it can be done through a VPN.



You are building a web application that will run in an AWS ElasticBeanstalk environment. You need to add and configure an Amazon ElastiCache cluster into the environment immediately after the application is deployed.

What is the most efficient method to ensure that the cluster is deployed immediately after the EB application is deployed?

  1. Use the AWS Management Console to create and configure the cluster.
  2. Create a cron job to schedule the cluster deployment using the aws cloudformation deploy command
  3. Create a configuration file with the .config extension and place it into the .ebextensions folder in the application package.
  4. Build an AWS Lambda function that polls to the ElasticBeanstalk environment deployments and create and configure the Amazon ElastiCache cluster.
Previous Lambda
Next RDS