AWS Database Services

Amazon ElastiCache

5 min read
Updated June 21, 2025
5,042 characters

Core Concepts

  • Node: A fixed-size chunk of secure, network-attached RAM, which is the smallest building block of an ElastiCache deployment. Each node runs the engine (Redis or Memcached) you select and has its own DNS name and port.
  • Cluster: A collection of one or more nodes.
  • Caching Strategies: Caching is most effective when:
    • Data is expensive or slow to acquire from the primary database.
    • Data is accessed very frequently.
    • Data is relatively static, or some degree of staleness is acceptable.
  • Common Use Cases: Database caching, web session storage, real-time analytics, leaderboards, and message queueing.

Engine Comparison: Redis vs. Memcached

Choosing the right engine is the most important decision when starting with ElastiCache.

Feature Redis Memcached
Primary Use Case Complex caching, session stores, leaderboards, pub/sub, geospatial data. Simple object caching for reducing database load.
Data Structures Supports advanced data structures: Strings, Lists, Sets, Sorted Sets, Hashes, Bitmaps. Supports simple key-value pairs (strings, objects).
Performance Model Primarily single-threaded. Multi-threaded, can offer better performance on multi-core nodes for simple get/set operations.
High Availability Yes. Supports Multi-AZ with automatic failover from a primary to a read replica. No native automatic failover. Must handle node failures in application logic.
Data Persistence Yes. Can create backups and snapshots of the cache data. Can be used as a primary data store. No. Purely an in-memory cache. Data is lost on restart or failure.
Replication Yes. Supports read replicas to scale read traffic and improve availability. No. Cannot replicate data across nodes.
Publish/Subscribe Yes. Built-in Pub/Sub messaging capabilities. No.
Transactions Yes. Supports transactions for executing multiple commands as a single atomic operation. No.
Geospatial Support Yes. Supports indexing and querying of geospatial data. No.
Security Supports Encryption in-transit & at-rest, and AUTH token for authentication. No encryption. Supports SASL authentication.

Rule of Thumb: Start with Redis unless you have a specific reason to use Memcached (e.g., existing Memcached environment or need for the simplest possible key-value cache). Redis offers far more features and flexibility.


Redis In-Depth

Redis Modes: Cluster vs. Non-Clustered

Redis on ElastiCache can run in two modes. The primary difference is the ability to partition (shard) data across multiple nodes for horizontal scaling.

Feature Redis (Cluster Mode Disabled) Redis (Cluster Mode Enabled)
Shards (Node Groups) Always 1 1 to 500
Data Partitioning No (all data on a single primary node) Yes (data is spread across multiple shards)
Scale Up (Vertical) Yes No
Multi-AZ Failover Yes (Optional) Yes (Required)
Promote Replica to Primary Yes No (failover is managed by the cluster)

Key Redis Features

  • High Availability: With Multi-AZ enabled, if the primary node fails, ElastiCache automatically promotes one of the up-to-5 read replicas to be the new primary.
  • Data Persistence: You can enable automatic snapshots and create manual backups of your Redis cluster, allowing you to restore data and providing durability.
  • Complex Data Structures:
    • Sorted Sets: Guarantees uniqueness and ordering of elements, making it perfect for building real-time leaderboards.
    • Hashes: Maps that store field-value pairs, ideal for representing objects.
  • Pub/Sub: A messaging paradigm where publishers send messages to channels, and subscribers receive messages from the channels they are subscribed to, without direct knowledge of each other.

Security

Encryption (Redis)

  • In-Transit Encryption: Encrypts data as it moves between your application and the ElastiCache cluster, and between nodes within the cluster. Enabling this can have a minor performance impact.
  • At-Rest Encryption: Encrypts on-disk data during sync operations and when creating backups/snapshots.
  • Both encryption features are only available for Redis clusters running in a VPC on supported versions (e.g., 3.2.6+).

Authentication

  • Redis AUTH: You can require clients to provide a token (password) using the AUTH command before they are allowed to execute commands. This improves data security by preventing unauthorized access.

Network Security

  • ElastiCache clusters should be launched in an Amazon VPC for network isolation.
  • Access to the cluster nodes is controlled via Security Groups. You must open the appropriate TCP port to allow your application servers to connect.
    • Default Redis Port: 6379
    • Default Memcached Port: 11211
      Sources