Skip to main content
Skip to main content
Still in beta — questions, comments or suggestions? aramb@aramb.dev

ElastiCache

Learn how Amazon ElastiCache improves application performance using in-memory caching with Redis and Memcached.

15 min
Introductory
Has Paid ComponentsPAID

Some services in this lesson have no free tier and will incur charges.

AWS Services Used

Amazon ElastiCachePricing based on node type or serverless usage

Learning outcomes

By the end of this lesson, you will be able to:

  1. Explain what Amazon ElastiCache is.
  2. Explain why caching makes applications faster.
  3. Recognize the main ElastiCache engine options: Valkey, Memcached, and Redis OSS.
  4. Distinguish between serverless caching and node-based clusters.
  5. Choose ElastiCache for common use cases like caching and leaderboards.

What ElastiCache does

ElastiCache is the “make reads faster” service. It provides a fully managed in-memory data store that acts as a lightning-fast layer in front of your primary database.

A simple memory rule:

  • Database = The "Source of Truth" (Permanent storage).
  • Cache = A "Fast Copy" (Temporary, high-speed storage).

1) What is Amazon ElastiCache?

Amazon ElastiCache is a web service that makes it easy to set up, manage, and scale a distributed in-memory data store in the cloud. Instead of your application reading from a disk-based database every time, it can read from RAM, which is significantly faster.

Key takeaway:

  • ElastiCache is not for permanent storage.
  • It is used to reduce latency and decrease the load on your primary database.

2) Why Caching Helps

Some data is accessed frequently but updated rarely (like a product description or a user's profile). Fetching this from memory is:

  • Faster: Sub-millisecond latency.
  • Cheaper: Reduces the need to scale up your expensive primary database.

Warning

Stale Data: Cached data is a copy. If the original database changes, the cache might still have the old version for a few minutes. This is called "stale data."


3) Main Engine Options

AWS supports three main engines for ElastiCache:

Memcached

A straightforward, high-performance in-memory key-value store. Best for simple caching needs where you just want to store and retrieve data quickly.

Redis OSS / Valkey

Richer in-memory data stores that support complex data structures like lists, sets, and sorted sets.

  • Best For: Gaming leaderboards, real-time messaging (pub/sub), and complex application state.

4) Serverless vs. Node-Based

ElastiCache Serverless

  • Simplicity: No need to choose instance types or manage clusters.
  • Scaling: Automatically scales memory and compute based on demand.
  • Best For: New applications or unpredictable workloads.

Node-Based Clusters

  • Control: You choose the specific node type (CPU/RAM) and number of nodes.
  • Optimization: Better for applications with very specific performance or cost requirements.

5) Common Use Cases

A) Database Caching

Store the results of expensive SQL queries so the next user gets the answer instantly.

B) Leaderboards

Use Redis sorted sets to track player rankings in real-time without hitting your main database.

C) Session Store

Store user login sessions in memory so the website feels snappy as users move between pages.


Micro-activity 1: Pick the Better Fit

Micro-Activity

Cache vs. Database

Should you use ElastiCache or just a Database for these needs?

Examples

Choose one, then match it on the right

Characteristics

Select an example first

0 of 5 matched so far.

Micro-activity 2: Serverless or Node?

Micro-Activity

Deployment Selection

Which ElastiCache option fits the situation?

Examples

Choose one, then match it on the right

Characteristics

Select an example first

0 of 4 matched so far.


Summary

Amazon ElastiCache is the secret to building high-performance AWS applications. By storing a "fast copy" of your data in memory using engines like Redis or Memcached, you can deliver sub-millisecond response times to your users while saving money on your primary database.


Knowledge Check

Knowledge Check
1 / 5

What is the primary purpose of Amazon ElastiCache?

Next lesson

Lesson 4.16: Redshift and EMR