Chapter 61 · Amazon Elasticache
Subchapter 61.30
references/monitoring/hot-key-detection.mdMarkdown11 KBView on GitHub
When to use: The user reports uneven shard load, one node pinned at high CPU while peers are idle, latency spikes correlated with specific request patterns, or suspected “hot key” problem. When not needed: Broadly high engine CPU across all shards (that’s capacity, not a hot key: see High CPU). Memory pressure with evictions is a different playbook (see Memory Pressure). Connection storms are not hot-key issues (see Connection Spikes).
troubleshooting.mdGiven a cluster with a suspected hot-key problem, answer three questions in order:
Each step has stop conditions. Do not proceed to the next step unless the current step confirms the problem.
Serverless → Tier A (CloudWatch) plus limited client-side diagnostics.
Tiers B and C are not available.
See "Serverless-specific considerations" below for the full diagnostic order.
Node-based → All tiers available, proceed through Check 2.Valkey 8.0+ cluster mode (node-based only) → Tier B (CLUSTER SLOT-STATS) is available and preferred.
Valkey 7.x, Redis OSS 7.x → Skip Tier B. Use Tier A to find the hot node, then Tier C.
Cluster mode disabled → Single shard. Skip Tier B. Tier A and Tier C only.Check engine version (use describe-cache-clusters which exposes both fields):
aws elasticache describe-cache-clusters \
--cache-cluster-id <node-id> --region <region> \
--query 'CacheClusters[0].[CacheNodeType,EngineVersion,Engine]'OBJECT FREQ requires an LFU policy (allkeys-lfu or volatile-lfu). CONFIG GET is restricted on all ElastiCache caches; check the parameter group instead:
aws elasticache describe-cache-parameters \
--cache-parameter-group-name <parameter-group-name> \
--query "Parameters[?ParameterName=='maxmemory-policy'].ParameterValue" \
--output text --region <region>maxmemory-policy takes effect immediately (no restart needed), then Tier C.valkey-cli --bigkeys, then client-side instrumentation. Note: valkey-cli --hotkeys also requires LFU.OBJECT FREQ.Always-available first step. Tells you whether the problem is real and narrows where to look.
Query EngineCPUUtilization per node using the CacheClusterId dimension. Do NOT query with ReplicationGroupId; the aggregate hides imbalance.
Note on CPU metrics:
EngineCPUUtilizationmeasures only the main Valkey/Redis OSS engine thread. On nodes with 4+ vCPUs where enhanced I/O features are active, network I/O and TLS processing are offloaded to dedicated I/O threads not captured byEngineCPUUtilization, so it may appear lower than expected. For smaller node types with 2 vCPUs or less, useCPUUtilizationinstead. Also checkTrafficManagementActive; a value of 1 indicates the node may be underscaled for the workload — ElastiCache is actively managing/throttling traffic to protect the engine.
aws cloudwatch get-metric-statistics \
--namespace AWS/ElastiCache \
--metric-name EngineCPUUtilization \
--dimensions Name=CacheClusterId,Value=<node-id> \
--start-time <1h-ago> --end-time <now> \
--period 60 --statistics Maximum \
--region <region>Run for each node (describe-cache-clusters --show-cache-node-info to list nodes).
Stop condition: If all nodes are within 15 percentage points of each other, this is not a hot-key problem. Route to the High CPU playbook in troubleshooting.md.
If one node is at least 1.5x the cluster median, proceed.
Query command-family metrics on the hot node: StringBasedCmds, HashBasedCmds, SetBasedCmds, SortedSetBasedCmds, ListBasedCmds, StreamBasedCmds, PubSubBasedCmds, JsonBasedCmds, SearchBasedCmds.
The family with the highest rate on the hot node points to the data type of the hot key.
Slow log delivery must be enabled via log delivery configuration (see log-delivery.md for setup). Search for repeated key patterns. A key appearing in many slow-log entries is a strong hot-key candidate, especially with HGETALL, SMEMBERS, LRANGE 0 -1, ZRANGE 0 -1, or SORT.
aws logs filter-log-events \
--log-group-name /aws/elasticache/<cluster-id>/slowlog \
--start-time <1h-ago-ms> \
--filter-pattern "<suspected-key-prefix>" \
--region <region>valkey-cli -h <endpoint> -p 6379 --tls LATENCY DOCTOR
valkey-cli -h <endpoint> -p 6379 --tls LATENCY LATEST
valkey-cli -h <endpoint> -p 6379 --tls LATENCY HISTORY <event-name>Serverless: the entire LATENCY * family is blocked. Use SuccessfulReadRequestLatency and SuccessfulWriteRequestLatency CloudWatch metrics at p50/p99/p100 instead.
Tier A summary (produce before proceeding):
CLUSTER SLOT-STATS reports per-slot command counts and CPU usage. Not available in Redis OSS or earlier Valkey. No LFU requirement.
| Signal | Typical value |
|---|---|
| Runtime | Subsecond on any cluster size |
| Throughput impact | Negligible |
| Production safe | Yes, use LIMIT 10 for bounded response |
valkey-cli -h <endpoint> -p 6379 --tls --cluster-yes \
CLUSTER SLOT-STATS ORDERBY CPU-USEC LIMIT 10Stop condition: If top 10 slots are within 2x of each other, no single hot slot. Reconsider whether the problem is command-family cost rather than a hot key.
valkey-cli -h <endpoint> -p 6379 --tls \
CLUSTER GETKEYSINSLOT <hot-slot-number> 200Cross-reference with MEMORY USAGE <key> and command family from Tier A Step 2.
Stop condition: If Tier A already identified a specific key in slow log that hashes into this slot (verify via CLUSTER KEYSLOT <key>), skip enumeration.
If LFU policy: proceed to Tier C on each candidate. If not LFU, use these alternatives in order:
aws logs filter-log-events, group by key, rank by frequency.MEMORY USAGE <key> per candidate. If one candidate is distinctly larger, that’s a strong big+hot signal.OBJECT FREQ reads the logarithmic frequency counter maintained under LFU policies. O(1) per call, safe to run at scale.
aws elasticache describe-cache-parameters \
--cache-parameter-group-name <parameter-group-name> \
--query "Parameters[?ParameterName=='maxmemory-policy'].ParameterValue" \
--output text --region <region>If not LFU, stop. The counter is meaningless under LRU.
valkey-cli -h <endpoint> -p 6379 --tls OBJECT FREQ <key>Interpreting the counter (logarithmic):
Rank candidates by OBJECT FREQ. Retrieve sizes via MEMORY USAGE <key> to determine whether the problem is request rate (fix with client-side caching or key splitting) or value size (fix with value decomposition).
Serverless: MONITOR is blocked. This section applies to node-based only.
MONITOR streams every command to the connected client. Do not use on production:
If genuinely the only option (no LFU, Tier B unavailable, client instrumentation not feasible):
valkey-cli MONITOR | head -n 100000OBJECT *, MEMORY *, LATENCY *, SLOWLOG *, COMMANDLOG (Valkey 8.1+; not available on serverless), CONFIG *, MONITOR, valkey-cli --hotkeys, valkey-cli --memkeys. valkey-cli --bigkeys works (uses SCAN + type-length commands).
ThrottledCmds to spot bursts.--bigkeys: client-side sample scan to identify large values. Run during off-peak.Ordered by preference. Pick the first that fits; layer in later options if needed.
hot:1 through hot:N), load-balance reads. Use when client-side caching is not feasible.HGETALL or LRANGE 0 -1.troubleshooting.md High CPU sectiontroubleshooting.md Replication Lag sectionalarm-packs.mdlog-delivery.md