Chapter 61 · Amazon Elasticache
Subchapter 61.4
references/data-modeling/memcached-recipe.mdMarkdown5 KBView on GitHub
Guidance for using Amazon ElastiCache for Memcached: when it fits, how it scales, and what it lacks.
Memcached is the right choice when all of the following are true:
Typical use case: Caching serialized database query results, HTML fragments, API responses, or computed objects where the source of truth is always the database and the cache is purely an acceleration layer.
Recommendation: Start with serverless Memcached unless you have a specific reason to manage nodes (e.g., cost optimization at very large steady-state scale).
ElastiCache Memcached supports Auto Discovery, which lets clients automatically detect when nodes are added or removed. The client connects to the cluster’s configuration endpoint (not individual node endpoints), polls for changes once per minute by default (this interval can be adjusted), and updates its node list without any application redeployment. See the ElastiCache Auto Discovery documentation (opens in a new tab) for implementation details.
Memcached clients use consistent hashing to distribute keys across nodes:
1/N where N is the number of nodes), rather than all keysThis minimizes cache misses during scaling events.
Adding capacity to a Memcached cluster:
For node-based, scaling is done via ModifyCacheCluster (CLI: aws elasticache modify-cache-cluster). For serverless Memcached, scaling is automatic within the configured CacheUsageLimits; adjust limits via modify-serverless-cache with --cache-usage-limits. See AWS docs for full parameter reference.
Switch to Valkey (or Redis OSS) if you need any of the following:
| Requirement | Why Memcached cannot help |
|---|---|
| Data persistence | Node-based Memcached is purely in-memory with no persistence. Serverless Memcached supports daily backup/restore but not RDB/AOF snapshots. |
| Replication / automatic failover | Node-based Memcached has no replicas. Serverless Memcached provides transparent Multi-AZ data redundancy. |
| Sorted sets, lists, streams, hashes | Memcached supports only string key-value pairs |
| Pub/sub messaging | Not supported |
| RBAC or IAM authentication | Not supported for Memcached |
| Vector search | Requires Valkey 8.2 or above node-based |
| Lua scripting or server-side logic | Not supported |
| Atomic data structure operations (INCR on hash fields, ZADD, etc.) | Limited to basic INCR/DECR on string counters |
Rule of thumb: If your use case goes beyond simple get/set/delete with TTL, use Valkey.