Cluster Hot Slots Heatmap — Technical Design Doc - Part 2 #509
nassery318
started this conversation in
Design
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Addressing: #470
Add cluster slot heatmap visualization
Part 1: #498
Overview
This document proposes the second part of the slot-level heatmap in the Hot Keys tab of the Activity view, on clusters running the hot-slots collection mode. Part 1 answers "where did my hot keys land." Part 2 answers "which slots are busy right now, how much of its node's work is one slot doing, and is the hot region a single slot or a run of neighbours" — the last of these matters because the two shapes call for opposite fixes.
Motivation
The original issue asks for three things: a heatmap of slot ranges coloured by CPU time, available only where slot stats are enabled, with drill-down from a hot slot to the keys inside it.
Part 1 delivered the drill-down, meets the availability condition by construction, and built the substrate the first item needs — the slot model and the entire component tree. What it does not do is colour by CPU or draw ranges. Three consequences make that worth extending Part 1:
Goal
The goal of Part 2 is to:
Current State — What Part 1 Ships
Hot-slots collection asks Valkey which slots are consuming the most CPU (
CLUSTER SLOT-STATS ORDERBY CPU-USEC), scans the keys inside each one, and ranks them by access frequency. Part 1 kept the slot attached through that path and built the view on top of it:Proposed Design
Stage 1 — Carry CPU time through to the UI
CPU time per slot is already fetched during collection and then dropped. Carrying it forward makes a slot a record in its own right rather than a grouping of keys: the collector returns per-slot summaries — slot, CPU time, keys scanned — as a second channel alongside the ranked key list. Each slot has exactly one owning primary, so per-node summaries concatenate without merging and without any risk of double-counting; aggregation only stamps the owner on.
The two channels differ in size on purpose. The key list is cut to a cluster-wide top N; the slot summaries are not. That difference is surfaced rather than hidden, and it is what lets a slot appear on the grid with no keys under it.
Stage 2 — Turn a counter into a rate
The CPU figure Valkey reports is cumulative: it accumulates for the life of the server and resets only when stats are reset. Colouring by it directly would answer "busy ever", not "busy now" — a confident-looking picture of the wrong number.
Turning it into a rate needs two samples, not a collection pipeline. The metrics process for a node is long-lived, so it holds the previous reply and the time it was taken, and the second refresh yields both figures the view needs:
The guards are the ones the node CPU view already applies: nothing is reported on a slot's first sample, nothing when no time has passed, and a negative change is discarded as a restart or a stats reset.
Two details make the differencing work. Ask for a wider set of slots than is scanned — requesting slot stats is a single cheap command, while scanning keys and reading their frequencies is the expensive part, so widening the stats request raises the chance a slot appears in both samples at almost no cost. And report the window the rate was measured over, since refreshes are user-driven and a rate averaged across ten minutes must not be read as an instantaneous one.
Stage 3 — Classify the shape
Rate and share say how hot a slot is. Whether its neighbours are hot too says what to do about it. Adjacent hot slots are folded into ranges before rendering, and the range is what the view reports:
This is what "slot ranges" in the issue points at, and it is the reading an operator performs by eye today. Stating it is the difference between a picture and a tool.
Stage 4 — Fix the scale
A handful of slots take almost all the traffic, so on a straight linear scale one extreme slot consumes nearly the whole colour range and flattens everything else into the palest band, hiding the second and third hotspots. The ramp becomes logarithmic or rank-based, with the top anchored at a high percentile and the number of slots above that anchor reported, so the colour is spent where the structure actually is.
This also closes a fault Part 1 records as a known deviation. Where every sampled slot holds the same count — including where only one slot came back — every tile currently renders at the deepest band, so a flat distribution reads as a cluster-wide emergency. The scale helper shared with the node heatmap already handles that case correctly; the slot grid's own copy does not. Using the shared one is the fix.
Slot Data Used
Metrics that drive intensity
Fields shown as reported
UI Component Breakdown
Summary chips
Part 1's chip row is retained in full — hot slots, hot keys, the node filter dropdown, and the count of nodes that failed to report, which keeps a shrunken total from being presented as complete. One chip is added: the share carried by the top slot, the figure that answers "is anything concentrated" before a single tile is read.
Slot tile and drill-down
Each tile shows its slot number and its share of its node, coloured by rate, with the full record on hover: rate, share, hot keys against keys scanned, owning node, and the measurement window. Ordering changes from hot key count to slot number, so neighbouring slots sit next to each other and a hot run reads as a block — that change is what makes the shape classification legible rather than merely computed, and a detected run is outlined as one region and labelled with its span.
Selecting a tile opens that slot's key list beside the grid exactly as in Part 1, with size and TTL per key, the owning node in the footer, and a click that closes the modal and selects the key in the key browser. Keys within a slot stay ordered by access frequency, a deliberate reversal of Part 1's "frequency is not shown in this view." The counter is too coarse to rank slots against each other, but ordering a handful of keys inside one slot is a much weaker claim, and the column is labelled approximate.
Slot Intensity Classification
Slots are shaded across the five bands of the shared ramp, driven by CPU rate, with the legend doubling as a multi-select filter as in Part 1.
Edge Cases
All reactions