How is a provisioned ElastiCache bill actually built?
ElastiCache cost optimization means paying only for the memory, throughput, and redundancy your workload actually needs. Teams usually come to it after noticing that a cluster sized for a launch-day peak, or for a guess, has run at a fraction of capacity for months. The provisioned bill has few line items, so oversizing is easy to find once you know where to look.
The main charge is node-hours: node type × node count. Every node bills at the full hourly rate, whether it is a primary or a replica. In cluster mode, node count is shards × (1 + replicas per shard). A cluster with 3 shards and 2 replicas each runs 9 nodes. Moving to the next node size roughly doubles the per-node rate. Adding one replica per shard to that cluster adds 3 more nodes, and adding a fourth shard adds 3 more. Redundancy and sharding decisions therefore drive cost as much as node size does.
AZ-a AZ-b AZ-c
Shard 1 [Primary] ----> [Replica] ----> [Replica]
Shard 2 [Replica] <---- [Primary] ----> [Replica]
Shard 3 [Replica] <---- [Replica] <---- [Primary]
^
app in AZ-a reading a shard 2 primary = cross-AZ traffic
node count = 3 shards x (1 primary + 2 replicas) = 9
| Bill component | What drives it | Lever that reduces it |
|---|---|---|
| Node-hours | Node type, shard count, replicas per shard | Right-size the type, trim replicas, consolidate shards |
| Backup storage | Snapshot size, retention period | Shorter retention, fewer manual snapshots |
| Cross-AZ data transfer | App traffic reaching nodes in another AZ | Route reads to same-AZ replicas, co-locate clients |
+------------------------+------------------------+------------------------+
| AZ-a | AZ-b | AZ-c |
+------------------------+------------------------+------------------------+
| +------------+ | | |
| | App client |---+------------------------+ | |
| +------------+ | | | | |
| same-AZ read | | cross-AZ write | | |
| (no charge) | | (billed) | | |
| +------------+ | | +------------+ | | +------------+ |
| | S1 Primary | | | | S1 Replica | | | | S1 Replica | |
| +------------+ | | +------------+ | | +------------+ |
| | | | | |
| +------------+ | | +------------+ | | +------------+ |
| | S2 Replica |<--+ | | S2 Primary |<--+ | | S2 Replica | |
| +------------+ | +------------+ | +------------+ |
| | | |
| +------------+ | +------------+ | +------------+ |
| | S3 Replica | | | S3 Replica | | | S3 Primary | |
| +------------+ | +------------+ | +------------+ |
+------------------------+------------------------+------------------------+
| node count = 3 shards x (1 primary + 2 replicas) = 9 billed nodes |
| replication: each primary -> its 2 replicas in the other AZs |
| billed transfer: app -> node in another AZ |
+--------------------------------------------------------------------------+
A 3-shard cluster with 2 replicas per shard spread across three AZs bills for 9 nodes. An app in AZ-a reading the shard 2 replica in its own AZ incurs no transfer charge, while its writes to the shard 2 primary in AZ-b are billed as cross-AZ data transfer.
Which metrics should you read before resizing Redis nodes?
Pull at least two weeks of data, including your busiest day and any window with a snapshot or failover. Use aws cloudwatch get-metric-statistics against the AWS/ElastiCache namespace, filtered by CacheClusterId, with --period 60 and --statistics Maximum Average. Requesting both statistics matters because averages flatten the short spikes that cause outages.
Redis executes commands on one main thread. On a node with eight vCPUs, CPUUtilization can read 15% while that one core is pinned. EngineCPUUtilization reports the engine thread directly, so base any CPU decision on it.
Memory needs a similar check. DatabaseMemoryUsagePercentage is calculated against usable memory, which already excludes the reserved-memory-percent set aside for forks and replication buffers. If you cut that reservation to fit a smaller node, a snapshot during heavy writes can trigger copy-on-write growth and swap. On the node itself, INFO memory gives used_memory and used_memory_rss. Their ratio is mem_fragmentation_ratio, which tells you how much RSS is waste. INFO stats gives keyspace_hits, keyspace_misses and evicted_keys.
| Metric | What it tells you | Warning sign |
|---|---|---|
EngineCPUUtilization |
Load on the command thread | Sustained peaks above roughly 80% |
DatabaseMemoryUsagePercentage |
Data size against usable memory | Near 100% with rising Evictions |
mem_fragmentation_ratio |
RSS overhead beyond data | Well above 1.5, or below 1 (swapping) |
CacheHitRate |
Whether the cache earns its cost | Falling while evictions climb |
NetworkBytesIn/Out |
Throughput against the instance's limit | Flat-topped peaks |
CurrConnections |
Client pool behaviour | Sudden jumps, or connection churn |
#!/usr/bin/env bash
# Pull 1-minute Maximum and Average for one node over a 24h window (e.g. your busiest day).
# A single call returns at most 1,440 datapoints, so at --period 60 query one day at a time.
set -euo pipefail
NODE="my-redis-0001-001" # placeholder CacheClusterId (one node)
START="2026-10-27T00:00:00Z"; END="2026-10-28T00:00:00Z"
for METRIC in EngineCPUUtilization CPUUtilization DatabaseMemoryUsagePercentage \
Evictions CacheHitRate NetworkBytesOut CurrConnections; do
echo "== $METRIC (timestamp, max, avg)"
aws cloudwatch get-metric-statistics \
--namespace AWS/ElastiCache --metric-name "$METRIC" \
--dimensions Name=CacheClusterId,Value="$NODE" \
--start-time "$START" --end-time "$END" \
--period 60 --statistics Maximum Average \
--query 'sort_by(Datapoints,&Timestamp)[].[Timestamp,Maximum,Average]' \
--output text | sort -k2 -n -r | head -5 # five highest one-minute peaks
done
# On the node: memory and fragmentation (INFO lines end in \r, so strip it).
# Add --tls if in-transit encryption is enabled on the cluster.
HOST="my-redis.xxxxxx.cache.amazonaws.com" # placeholder endpoint
redis-cli -h "$HOST" -p 6379 INFO memory | tr -d '\r' \
| grep -E '^(used_memory|used_memory_rss|used_memory_peak|maxmemory|mem_fragmentation_ratio):'
# Hit ratio and evictions since the last restart or stats reset (cumulative counters).
redis-cli -h "$HOST" -p 6379 INFO stats | tr -d '\r' | awk -F: '
$1=="keyspace_hits" {h=$2}
$1=="keyspace_misses" {m=$2}
$1=="evicted_keys" {e=$2}
END { if (h+m > 0) printf "hit_ratio=%.3f evicted_keys=%d\n", h/(h+m), e }'
Pulls per-minute Maximum and Average CloudWatch statistics for one node's busiest day and reads fragmentation, hit ratio and evictions directly from INFO memory and INFO stats.
How do you size Redis nodes by memory and when should you scale out instead of up?
Start from peak BytesUsedForCache over several weeks, not the average. Then add the overhead the dataset doesn't show. Fragmentation inflates resident memory. Background saves and replica syncs fork the process, so copy-on-write pages grow with your write rate. Replication buffers also need room. ElastiCache sets aside reserved memory for this, and you should size against the memory left after that reservation.
Illustrative estimate (all inputs assumed): peak data is 18 GiB and fragmentation is 1.2, giving 21.6 GiB resident. Reserving 25% for forks and buffers means you need 21.6 / 0.75 ≈ 28.8 GiB. Add 20% for growth and you need a node with about 35 GiB. If the next node size up is far larger, two shards of about 18 GiB each may cost less and leave each fork smaller.
Scale out with cluster mode when a single node's memory, network or single-threaded command processing is the limit. Sharding only helps if keys spread evenly. A hot key, or a hash tag that pins related keys to one slot, keeps one shard saturated while the others sit idle.
Resizing and resharding carry their own cost. Schedule them in a maintenance window, expect higher latency while data migrates, and confirm that clients handle MOVED redirects and refresh the topology.
The trade-offs run in both directions:
- Undersizing causes evictions and a falling hit ratio, and those misses fall through to a database that costs more to scale.
- Cutting headroom too far risks swapping, slow saves and failed replica syncs.
- Dropping replicas saves money but lowers availability, and it removes read capacity that read-heavy workloads may depend on.
Can reducing what you store save more than changing node type?
Before changing node types, check how much of the dataset you need at all. Shrinking the data lowers the bill on every node, including replicas, and you avoid the resharding and failover testing that a resize requires.
Find what is taking up memory
- Large keys:
redis-cli --bigkeysreports the biggest key of each type.MEMORY USAGE <key>gives a per-key byte count, including overhead. - Idle keys:
OBJECT IDLETIME <key>returns the seconds since the key was last accessed. It returns an error when an LFU eviction policy is active. - TTL coverage: sample keys with
SCANand record the share that has no TTL. Keys without one are often left behind by deleted features.
Scan safely in production
Use SCAN with a modest COUNT, never KEYS. Run it against a replica, outside peak hours, and watch latency while it runs.
Fix what you find
- Set a TTL on every key, either with
EXPIREor on write withSET ... EX. Add random jitter to TTLs so large batches of keys don't expire at the same moment. - Store small objects as hashes that fit within the compact-encoding thresholds in your parameter group.
- Replace verbose JSON with a compact binary serialization format, or compress large values.
- Decide whether each key prefix is worth its memory by comparing its size to its hit rate.
Illustrative estimate (assumed numbers, not a benchmark):
New size = current × (1 − idle fraction) × (1 − encoding savings)
Assume a 40 GB dataset, 30% idle keys, and 25% savings from a more compact format:
40 × 0.7 × 0.75 = 21 GB
With those assumptions, the dataset might fit on a node class one size smaller.
#!/usr/bin/env bash
# Sample a replica to see where memory goes. Run off-peak and watch latency.
# Cluster mode: repeat per shard (each shard holds only its own keys).
set -euo pipefail
HOST="replica.example-cache.internal" # placeholder: a replica endpoint, not the primary
CLI=(redis-cli -h "$HOST" -p 6379 --tls) # drop --tls if in-transit encryption is off
SAMPLE=1000
# 1. Biggest key per type. -i 0.1 sleeps between SCAN batches to limit load.
"${CLI[@]}" --bigkeys -i 0.1
# 2. Sample keys with SCAN (never KEYS). Record TTL, bytes, and idle seconds.
# OBJECT IDLETIME does not reset the idle clock, but it errors under an LFU policy.
# This loop assumes key names without newlines.
"${CLI[@]}" --scan -i 0.01 | head -n "$SAMPLE" | while IFS= read -r key; do
ttl=$("${CLI[@]}" TTL "$key")
bytes=$("${CLI[@]}" MEMORY USAGE "$key")
idle=$("${CLI[@]}" OBJECT IDLETIME "$key" 2>/dev/null || echo "n/a")
printf '%s\t%s\t%s\t%s\n' "$key" "$ttl" "$bytes" "$idle"
done > sample.tsv
# 3. Summarize: TTL -1 means no expiry; idle > 7 days is a cleanup candidate.
awk -F'\t' '
{ n++; total += $3 }
$2 == -1 { nottl++; nottl_bytes += $3 }
$4 != "n/a" && $4 > 604800 { idle++; idle_bytes += $3 }
END {
printf "sampled=%d no_ttl=%.1f%% (%.1f%% of bytes)\n", n, 100*nottl/n, 100*nottl_bytes/total
printf "idle>7d=%.1f%% (%.1f%% of bytes)\n", 100*idle/n, 100*idle_bytes/total
}' sample.tsv
# 4. Fix on write against the primary: always set a TTL, with jitter so
# keys written together do not all expire at the same moment.
# redis-cli -h primary.example-cache.internal --tls \
# SET "session:42" "$payload" EX $((3600 + RANDOM % 600))
A bash script that runs --bigkeys and a throttled SCAN sample against a replica, records TTL, MEMORY USAGE and OBJECT IDLETIME for each sampled key, and summarizes the share of keys and bytes with no TTL or long idle times, followed by a jittered SET ... EX for new writes.
How does ElastiCache Serverless pricing work and when should you avoid it?
ElastiCache Serverless removes nodes from the bill. You pay for two things: the data you store, metered over time, and the compute your requests consume, measured in ElastiCache Processing Units (ECPUs). A simple GET or SET on a small value costs a baseline amount. Larger payloads and heavier commands cost proportionally more. Each cache also has a minimum billable data amount, so a nearly empty cache is still charged for that floor. Rates and the floor size vary by engine and region and have changed over time, so check the current AWS pricing page rather than relying on remembered figures.
| Dimension | Provisioned nodes | Serverless |
|---|---|---|
| Billing unit | Node-hours per node type | Stored data over time plus ECPUs |
| Control | You choose node type, shard count and replicas | AWS manages capacity; you can set usage limits |
| Scaling behavior | Manual or scheduled resharding and resizing | Automatic, driven by load |
| Operational effort | Capacity planning and resize operations | Mostly setting limits and watching spend |
| Best-fit workload shape | Large, steady, high-throughput | Spiky, unpredictable or new |
Serverless suits traffic you cannot forecast, new services without usage history, and teams that want to stop doing capacity planning. With a node, you pay for peak capacity around the clock. With Serverless, idle hours cost little compute.
Avoid it in three cases:
- Large, steady, high-throughput workloads. Per-request billing adds up quickly here, and a well-sized provisioned cluster running near capacity is usually cheaper.
- Very small caches. The data floor can make Serverless cost more than a small node.
- Strict tail-latency requirements. You give up direct control over capacity, so load-test sudden traffic spikes before you commit.
How do you compare Serverless and provisioned costs for your own workload?
Price both options from the same workload profile. The key difference is what each one bills for. Serverless bills on average stored data and actual request volume. Provisioned bills for capacity sized to your peak plus headroom, whether or not you use it. Pull four inputs from your metrics: average data size, peak data size, average requests per second, and the ECPUs each request consumes. Larger values and heavier commands cost more ECPUs.
Illustrative estimate (assumed numbers, not a benchmark). Replace every rate below with current regional pricing.
| Input / result | Assumed value | Formula |
|---|---|---|
| Hours per month (H) | 730 | — |
| Serverless storage rate (S) | $0.10 per GB-hour | — |
| Serverless ECPU rate (E) | $0.0034 per million ECPUs | — |
| Average data (D) | 10 GB | — |
| Average requests (R), 1 ECPU each | 5,000/s | — |
| Provisioned node rate (N), 2 nodes | $0.20/hour | — |
| Serverless storage cost | $730 | D × S × H |
| Serverless request cost | ≈ $45 | R × 3600 × H ÷ 1,000,000 × E |
| Serverless total | ≈ $775 | sum of the two |
| Provisioned total | $292 | nodes × N × H |
| Break-even average data | ≈ 3.4 GB | (provisioned − request cost) ÷ (S × H) |
With these assumptions, storage dominates the Serverless bill. Serverless becomes cheaper only when average data stays below about 3.4 GB, or when the provisioned cluster is oversized for a short daily peak. A spreadsheet with one row per input and these formulas in the result cells lets you rerun the comparison after any pricing change. Recompute the break-even with your ECPU-per-request figure, because large values shift it quickly.
# Illustrative estimate: every rate below is an ASSUMED placeholder.
# Replace them with current regional pricing before using the output.
HOURS = 730 # hours per month
STORAGE_RATE = 0.10 # assumed Serverless $ per GB-hour
ECPU_RATE = 0.0034 # assumed Serverless $ per million ECPUs
NODE_RATE = 0.20 # assumed provisioned $ per node-hour
# Workload inputs: pull these from your own metrics.
avg_data_gb = 10 # average stored data
nodes = 2 # nodes needed for PEAK data plus headroom
avg_rps = 5000 # average requests per second
ecpu_per_req = 1.0 # raise this for large values or heavy commands
def serverless_cost(data_gb, rps, ecpu):
storage = data_gb * STORAGE_RATE * HOURS
requests = rps * 3600 * HOURS * ecpu / 1_000_000 * ECPU_RATE
return storage, requests
storage, requests = serverless_cost(avg_data_gb, avg_rps, ecpu_per_req)
provisioned = nodes * NODE_RATE * HOURS
print(f"Serverless storage: ${storage:,.2f}")
print(f"Serverless requests: ${requests:,.2f}")
print(f"Serverless total: ${storage + requests:,.2f}")
print(f"Provisioned total: ${provisioned:,.2f}")
# Crossover: average data size at which both monthly bills are equal.
break_even_gb = (provisioned - requests) / (STORAGE_RATE * HOURS)
if break_even_gb <= 0:
print("Request cost alone exceeds provisioned; Serverless is never cheaper here.")
else:
print(f"Serverless is cheaper below ~{break_even_gb:.1f} GB average data")
A Python script that computes Serverless and provisioned monthly costs from assumed placeholder rates and your workload inputs, then reports the break-even average data size.
What are the alternatives: Valkey migration and reserved nodes?
Two levers remain once the workload itself is lean: the engine you run and the commitment you sign.
Engine choice: Valkey
ElastiCache offers Valkey alongside Redis OSS, and Valkey nodes are priced lower. Before a Valkey migration, check:
- Commands and clients. Inventory the commands your services issue, including Lua scripts, and confirm your client libraries are supported against the target engine.
- Modules and extensions. If you depend on anything beyond core data structures, confirm it exists on the target engine before anything else.
- A test cluster under production-like traffic. Replay or mirror real load to catch latency shifts and eviction differences that unit tests miss.
- A rollback plan. Keep the original cluster available until you trust the new one, and know how clients get repointed.
The per-node savings are modest compared with the cost of a cutover that empties a cache under peak load and sends the full read volume to your database.
Commitment discounts: reserved nodes
Reserved nodes discount a stable provisioned baseline in exchange for a one- or three-year term. That commitment is why they come last. If you reserve before right-sizing, you lock in oversized capacity. If you reserve before deciding on Serverless or Valkey, the discount applies to capacity you may stop using.
| Lever | Typical effort | Risk | When to apply |
|---|---|---|---|
| Shrink stored data | Medium | Low | First, after measuring |
| Right-size nodes | Low–medium | Low | After data shrinks |
| Serverless | Medium | Medium | Spiky or unpredictable load |
| Valkey migration | Medium–high | Medium | Once compatibility is verified |
| Reserved nodes | Low | Lock-in | Last, on a stable baseline |
Recommended sequence:
- Measure.
- Shrink data.
- Right-size.
- Decide on Serverless or an engine change.
- Commit.
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 optimization, 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.
- Changing a route's URL or method automatically notifies the services that consume it — no hunting through repos for callers.
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.
- Consumers learn about a breaking change at review time rather than from production errors.
- 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.