How much memory does your Redis workload actually need?
ElastiCache cost reduction means paying only for the memory, throughput and availability a workload actually uses. Order matters. Reserved nodes discount a specific node type for a fixed term, so reserving an oversized cluster commits you to the overprovisioning for the whole term. Size first, then reserve.
Nominal node RAM is not your budget. A sound memory requirement adds up:
- Dataset size: keys, values and per-key overhead.
- Copy-on-write overhead: background saves and full replica syncs fork the process. Every page written during the fork is duplicated, so write-heavy periods can require substantial extra memory.
- Fragmentation: allocator waste, visible as the gap between
used_memoryandused_memory_rss. - Client and replication buffers: output buffers for slow consumers, pub/sub subscribers and replicas.
Read the actual figures. BytesUsedForCache shows what Redis has allocated. DatabaseMemoryUsagePercentage shows that figure relative to maxmemory, which is the point at which eviction starts. FreeableMemory reports what remains on the host, and that remainder is what a fork draws on. In INFO memory, check used_memory, used_memory_rss, mem_fragmentation_ratio and maxmemory. Look at peaks during write bursts, not averages.
Set reserved-memory-percent in the parameter group so that memory outside maxmemory is available for forks and buffers. Too little causes failed saves, replica sync loops or out-of-memory errors.
Choose maxmemory-policy deliberately:
- Pure cache: an LRU or LFU policy suits it.
- Data that must not be dropped: needs
noevictionplus enough headroom, because writes fail once memory is full.
#!/usr/bin/env bash
set -euo pipefail
HOST="my-redis.xxxxxx.ng.0001.use1.cache.amazonaws.com" # placeholder endpoint
NODE_ID="my-redis-001" # node-level CacheClusterId
PARAM_GROUP="my-redis-params" # custom parameter group
redis-cli -h "$HOST" -p 6379 --tls INFO memory \
| grep -E '^(used_memory|used_memory_rss|used_memory_peak|mem_fragmentation_ratio|maxmemory|maxmemory_policy):'
START=$(date -u -d '14 days ago' +%Y-%m-%dT%H:%M:%SZ)
END=$(date -u +%Y-%m-%dT%H:%M:%SZ)
for m in BytesUsedForCache:Maximum DatabaseMemoryUsagePercentage:Maximum FreeableMemory:Minimum; do
aws cloudwatch get-metric-statistics \
--namespace AWS/ElastiCache \
--metric-name "${m%%:*}" \
--dimensions Name=CacheClusterId,Value="$NODE_ID" \
--start-time "$START" --end-time "$END" \
--period 3600 --statistics "${m##*:}" \
--query "sort_by(Datapoints,&Timestamp)[-5:]" --output table
done
aws elasticache modify-cache-parameter-group \
--cache-parameter-group-name "$PARAM_GROUP" \
--parameter-name-values \
"ParameterName=reserved-memory-percent,ParameterValue=25" \
"ParameterName=maxmemory-policy,ParameterValue=allkeys-lru"
A script that reads INFO memory and peak CloudWatch memory metrics for a Redis node, then sets reserved-memory-percent and maxmemory-policy in a custom parameter group before you commit to a node size.
How does right-sizing before reserving work?
Provisioned (node-based) ElastiCache bills each node per hour at a rate set by its node type and region. Replicas are billed the same way as primaries. Total cost is roughly node-hour rate × number of nodes × hours running. You can reduce it by lowering any of those factors: choose a smaller or cheaper node type, run fewer nodes (shards or replicas), or run nodes for fewer hours (non-production clusters).
A reserved node does not change what runs. It is a billing commitment for a node type in a region for a one- or three-year term. While matching nodes are running, they are billed at the discounted rate instead of on-demand. If no running node matches, you still pay for the commitment.
The approach therefore works in two phases:
- Right-size. Measure the real constraint (memory with headroom, engine CPU, network, connections), as described in the sections below. Then change node type, shard count, replica count and dataset size until the cluster fits measured peak load with deliberate headroom and no wasted capacity.
- Reserve. After the new configuration has held up through a representative period, buy reservations that match the node types and counts that remain stable. This locks the discount onto a footprint you already know you need.
If you reverse the order, the discount is attached to the old node shape. Every later right-sizing change then risks leaving a reservation that no running node matches.
Why doesn't a bigger node make Redis faster?
Redis executes commands on one main thread. Newer engine versions, and ElastiCache's own enhancements on larger node types, can move network I/O onto extra threads, but command execution itself stays serialized. A node with 16 vCPUs does not run a SET or a Lua script sixteen times faster than a node with 2. Moving up a size within the same family mostly buys more RAM and some network headroom. If memory was not the constraint, you pay for capacity the workload never touches.
That is why host CPU is a misleading signal. On a 4-vCPU node, a fully saturated engine thread can show around 25% in CPUUtilization, which looks healthy while latency climbs. ElastiCache publishes EngineCPUUtilization for exactly this reason: it reports the Redis process's thread. Base scaling decisions on that metric. When it runs hot, look first for expensive commands (KEYS, large SMEMBERS or HGETALL calls, long-running scripts) or uneven key distribution. A bigger instance will not fix either problem.
Some workloads never reach CPU or memory limits at all. Large values or high fan-out reads can exhaust the instance's network bandwidth allowance, which on smaller types relies on burst credits that eventually run out. Clients that open a new connection per request, or large fleets with oversized connection pools, can bottleneck on connection count and TLS handshakes. Check network throughput and CurrConnections/NewConnections alongside memory and engine CPU before you choose a node size. Otherwise you may right-size for the wrong constraint.
Should you scale up, scale out, or change node family?
Each option relieves a different bottleneck, so match the change to the metric that is actually saturated.
| Option | Memory | CPU | Network | Operational risk |
|---|---|---|---|---|
| Scale up (larger node) | More per node | Main engine thread gains little | Higher per-node bandwidth | Node replacement, failover |
| Scale out (more shards) | Spread across shards | Commands spread across shards | Aggregate bandwidth grows | Slot migration, multi-key limits |
| Change family | Memory-optimized gives more RAM per dollar | General purpose gives more CPU per GB | Varies by size | Node replacement, benchmark first |
Graviton-based nodes are often cheaper per GB than comparable x86 nodes, but benchmark your own command mix before you switch.
Illustrative estimate. These inputs are assumed and are not real prices. You have a 70 GB dataset and keep 25% of memory free for overhead.
- Scale up: one large node with about 100 GB at $1.80/hour.
- Scale out: three shards of about 35 GB each at $0.45/hour per node, which is $1.35/hour.
Adding one replica per shard doubles both totals, to $3.60 and $2.70. Scaling out also leaves room to add a shard later instead of jumping to the next node size.
Live-change risks. Online resharding moves hash slots between shards. That raises CPU and latency while it runs, and clients receive MOVED and ASK redirects. Changing node type replaces nodes and ends with a failover, which drops connections. Schedule both kinds of change in a maintenance window. Before you start, confirm in staging that your client library:
- refreshes cluster topology,
- retries with backoff,
- reconnects cleanly after a primary changes.
Assumed: 70 GB dataset, 25% memory kept free (illustrative estimate)
|
+--------------------+--------------------+
| |
v v
+-------------------+ +------------------------------------------+
| SCALE UP | | SCALE OUT (cluster mode) |
| 1 node, ~100 GB | | +----------+ +----------+ +----------+ |
| $1.80/hr | | | Shard 1 | | Shard 2 | | Shard 3 | |
| +1 replica: $3.60 | | | ~35 GB | | ~35 GB | | ~35 GB | |
+-------------------+ | | $0.45/hr | | $0.45/hr | | $0.45/hr | |
| | +----------+ +----------+ +----------+ |
| | $1.35/hr; +1 replica/shard: $2.70/hr |
| +------------------------------------------+
| |
v node type change v online resharding
+----------------------------+ +-------------------------------------+
| Node replacement | | Hash slots migrate between shards |
| Failover drops connections | | CPU/latency rise; MOVED/ASK replies |
+----------------------------+ +-------------------------------------+
| |
+--------------------+--------------------+
v
+-----------------------------------------------------------+
| Maintenance window + client behavior tested in staging: |
| refresh topology -> retry w/ backoff -> reconnect |
+-----------------------------------------------------------+
Illustrative estimate with assumed prices: scaling up versus scaling out a 70 GB dataset, and the live-change risks of each path that call for a maintenance window and client reconnect behavior tested in staging.
Which clusters need replicas and Multi-AZ, and which can be cut?
Each replica is a full-size node billed at the same hourly rate as the primary. A shard with two replicas therefore costs roughly three times a single node. Start the audit by listing every replication group with its environment tag, replica count per shard, and whether Multi-AZ with automatic failover is enabled. Then ask what each replica is actually for.
Replicas serve two purposes: availability (a promotable copy in another Availability Zone) and read scaling (clients sending reads to replica endpoints). Check your client configuration before cutting. If the application never reads from replicas, they exist only for failover.
| Environment | Typical need | Suggested shape |
|---|---|---|
| Production, cache in front of a database | Fast failover, protect the database | 1 replica per shard, Multi-AZ on |
| Production, read-heavy | Read throughput plus failover | Replicas sized to measured read load |
| Staging | Realistic failover testing | 1 replica, possibly smaller nodes |
| Dev / CI | None | Single node, no Multi-AZ |
| Ephemeral test | None | Create from snapshot, delete when idle |
Node-based clusters can't be paused. To save money outside working hours, you have to snapshot the cluster, delete it, and recreate it on a schedule.
The trade-off sits in production. Without a replica, losing a primary means a replacement node has to launch and the cache comes back cold. While the cache refills, every request misses and goes to the database. If the database is sized for the cache's hit rate, that spike can cause timeouts, throttling, or an emergency database scale-up. Any of those outcomes can cost more than a year of replica savings.
How can you shrink the dataset before paying for more RAM?
Before buying more RAM, check how much of the current RAM holds data you actually need. Three sources of waste are common.
Keys that never expire. INFO keyspace reports, per database, the total key count and how many keys have an expiry set. A large gap between the two means data accumulates indefinitely. Sample keys with SCAN and check TTL (a return of -1 means no expiry) to see which key prefixes are responsible. Leftover session data, feature flags from retired experiments, and one-off migration artifacts are frequent causes.
Oversized keys. redis-cli --bigkeys scans the keyspace and reports the largest key of each type. MEMORY USAGE <key> returns the bytes a specific key consumes, including overhead. One unbounded list or a hash that grew to millions of fields can use more memory than thousands of normal keys combined. It can also block the server during reads.
Inefficient representation. Small hashes, sets, and sorted sets use compact internal encodings until they cross configurable size thresholds. You can confirm the current encoding with OBJECT ENCODING. Grouping many tiny string keys into hashes reduces per-key overhead. Compact binary serialization formats and compression of large values cut memory further. The tradeoff is CPU time on the client.
Every one of these changes also affects behavior, not only memory. Shorter TTLs and trimmed collections mean more cache misses, and every miss goes to the primary datastore. Track hit ratio next to the cache bill, using keyspace_hits and keyspace_misses from INFO stats or the CloudWatch hit-rate metric, so the saving doesn't reappear as database load.
#!/usr/bin/env bash
set -eu
HOST="${REDIS_HOST:-my-cache-ro.example.internal}"
PORT="${REDIS_PORT:-6379}"
R=(redis-cli -h "$HOST" -p "$PORT")
"${R[@]}" INFO keyspace
"${R[@]}" --scan --count 1000 | head -n 2000 | while IFS= read -r key; do
if [ "$("${R[@]}" TTL "$key")" = "-1" ]; then
echo "${key%%:*}" # prefix before the first ':'
fi
done | sort | uniq -c | sort -rn | head -n 10
"${R[@]}" --bigkeys
KEY="session:user:48213"
"${R[@]}" MEMORY USAGE "$KEY"
"${R[@]}" OBJECT ENCODING "$KEY"
"${R[@]}" INFO stats | awk -F: '
/^keyspace_hits/ { h = $2 + 0 }
/^keyspace_misses/ { m = $2 + 0 }
END { if (h + m > 0) printf "hit ratio: %.2f%% (%d hits, %d misses)\n", 100*h/(h+m), h, m
else print "no reads recorded yet" }'
A redis-cli audit script that compares total keys with keys that have a TTL, groups sampled no-TTL keys by prefix, finds big keys, checks one key's memory use and encoding, and reports the hit ratio so you can watch it while you trim data.
What are the alternatives: reserved nodes, Valkey migration, or serverless?
Reserved nodes are a billing discount, not a resource. You commit to a node type in a region for a one- or three-year term and choose how much to pay upfront: none, partial, or all. Paying more upfront and committing longer gives a bigger discount. The reservation applies automatically to running nodes that match it. Check the current terms for how much flexibility exists within a node family. Moving to a different family or region will not match an existing reservation. This is why sections 1–5 come first. If you reserve before right-sizing and then shrink nodes, move from r-family to m-family, or switch engines, you can end up paying for a reservation that no node uses. Reserve only the baseline that has stayed stable for months, and leave growth and seasonal peaks on-demand.
ElastiCache prices Valkey below Redis OSS. For most workloads that use standard Redis commands, a Valkey migration is a cheap change. Before you migrate, check three things:
- Your client libraries work with Valkey.
- You don't depend on modules or features that Valkey lacks.
- Your existing Redis OSS reservations carry over to Valkey nodes.
Confirm current prices yourself.
Serverless ElastiCache bills for data stored and for compute consumed. You don't size or pay for idle nodes.
| Option | Fits | Watch for |
|---|---|---|
| Reserved nodes | Stable, right-sized baseline | Stranded commitment after resizing |
| Valkey migration | Standard Redis workloads | Client, module and reservation compatibility |
| Serverless | Spiky, unpredictable, or low-duty traffic | Higher cost under sustained high throughput |
Serverless can cost more than provisioned nodes when traffic is steady and high. Price both options using your own measured CloudWatch usage, not list-price assumptions.
Who should use this approach?
Right-sizing before reserving suits teams that run provisioned, node-based ElastiCache clusters and expect to keep them for at least the length of a reservation term. It pays off most for:
- Clusters with steady, predictable load. Production caches, session stores and leaderboards whose traffic follows a daily or weekly pattern that repeats, so a measured peak is a reliable sizing target.
- Clusters that were sized by guesswork. For example, they were provisioned at launch "to be safe", copied from another environment, or scaled up during an incident and never scaled back.
- Organizations with many clusters. Platform, SRE or FinOps engineers responsible for dozens of replication groups across environments, where replica counts, Multi-AZ settings and non-production clusters can be audited as a batch.
- Teams about to buy or renew reservations. A reservation purchase or expiry is the natural point to right-size, because it is the moment when the node shape is not yet locked in.
You need access to CloudWatch metrics, the ability to run redis-cli against at least a replica, and permission to change parameter groups and node configuration in a maintenance window.
When should you avoid it?
Skip or postpone the exercise when the effort or risk outweighs the savings, or when a reservation would not stay matched:
- Serverless caches. There are no nodes to size or reserve. Cost work there means reducing stored data and expensive requests instead.
- Short-lived or soon-to-change clusters. If you plan to migrate engines, change node family, move regions, or retire the workload within the term, a reservation is likely to end up unmatched. Right-size if it helps, but don't reserve.
- Fast-growing or unpredictable traffic. If the baseline keeps shifting, today's right size is wrong next quarter. Stay on-demand, or consider serverless, until the load stabilizes.
- No representative data. If you can't capture a real peak (a new service, or a seasonal business outside its season), sizing to the data you have will undersize the cluster.
- Small clusters. When the engineering time costs more than the annual saving, leave the cluster alone (see the illustrative calculation below).
- Caches that hold data you can't rebuild. If Redis is the only copy of the data and runs with
noeviction, cutting memory or replicas risks write failures or data loss. Tighten sizing only after you have tested headroom and recovery. - During incidents or freeze periods. Node replacements and resharding cause failovers and latency spikes. Don't stack them on top of an unstable system.
A repeatable ElastiCache cost review process
Run the review on a fixed schedule, such as quarterly and before any reservation expires, so it becomes a checklist instead of a reaction to a surprise bill.
The steps
- Baseline. Collect at least two weeks of CloudWatch data, including a known peak such as month-end or a release. Record memory usage,
Evictions,CacheHitRate,EngineCPUUtilization, network throughput and client-side p99 latency. A quiet week will make the cluster look oversized when it isn't. - Rank changes. List each candidate change, such as a smaller node, fewer replicas, TTL fixes or a family change. Score each one by monthly savings and by blast radius. Do the low-risk, high-savings items first.
- Stage the rollout. Change one cluster at a time, starting with non-production. Write the rollback criteria down before the change. For example, roll back if evictions rise above zero, hit ratio drops more than a few points, p99 latency exceeds your SLO, or engine CPU stays near saturation at peak.
- Re-measure, then reserve. Wait through another representative period on the new configuration. Only then buy reservations, sized to the setup that actually held up under load.
The written checklist and thresholds are what save engineering time. The next reviewer reruns the same steps instead of rebuilding the analysis from scratch.
When to skip
Illustrative estimate (assumed numbers, not a benchmark):
Annual savings = monthly cluster cost × expected reduction × 12
Review cost = engineer hours × loaded hourly rate
Assume a $300/month cluster and a 30% reduction. Annual savings are $300 × 0.30 × 12 = $1,080. Now assume the review takes 16 hours at $100/hour, which costs $1,600.
When the review cost exceeds the annual savings, as it does here, skip the exercise. Revisit the cluster when its bill grows.
#!/usr/bin/env bash
set -euo pipefail
CLUSTER_ID="orders-cache-0001-001" # placeholder node ID (CacheClusterId)
REGION="us-east-1"
DAYS=14 # widen this if the window misses month-end or a release
PERIOD=3600 # 1-hour buckets: 14 days = 336 datapoints per metric
START=$(date -u -d "-${DAYS} days" +%Y-%m-%dT%H:%M:%SZ) # GNU date syntax
END=$(date -u +%Y-%m-%dT%H:%M:%SZ)
METRICS="Evictions CacheHitRate EngineCPUUtilization DatabaseMemoryUsagePercentage NetworkBytesIn NetworkBytesOut"
for METRIC in $METRICS; do
echo "== ${METRIC} (peak hourly Maximum / mean of hourly Averages) =="
aws cloudwatch get-metric-statistics \
--region "$REGION" \
--namespace AWS/ElastiCache \
--metric-name "$METRIC" \
--dimensions Name=CacheClusterId,Value="$CLUSTER_ID" \
--start-time "$START" \
--end-time "$END" \
--period "$PERIOD" \
--statistics Maximum Average \
--query '[max(Datapoints[].Maximum), avg(Datapoints[].Average)]' \
--output text
done
A rerunnable shell script that captures the two-week CloudWatch baseline for one ElastiCache node, recording peak and average values for evictions, hit rate, engine CPU, memory and network, so every review compares against the same measurements.
How OneEnv can help
Disclosure: OneEnv is the product behind this blog.
OneEnv (oneenv.io) is a workspace-based governance platform for the things services share — environment variables, database structure, API routes and validation rules. A change to a shared value is staged on a branch, reviewed once, and then every affected service explicitly approves or rejects it before it goes live, so you can see who a change touches before it ships instead of finding out in production.
Applied to elasticache cost reduction, this is where it helps:
Saves time
- Every service that inherits a shared value is listed in one place, so nobody searches repos and chats to find out who is affected.
- One review per branch replaces coordinating each team separately; each service still keeps its own approve/reject.
- Reviewers see the exact diff and the list of affected services up front, so approval is a decision rather than an investigation.
Saves cost
- Fewer production incidents and rollbacks caused by a shared value, route or column changing under a consumer unannounced.
- Less duplicated configuration to maintain: one shared definition inherited by many services.
- Per-service approve/reject means a bad shared value can be refused where it would break something, before it is live.
- OneEnv has a free plan (1 workspace, unlimited services and members, full governance), so trying it costs nothing.
These are qualitative benefits, not measured results — how much you save depends on how many services share the value.
Want to try it? Start at oneenv.io.