New in BetterDB Monitor v0.56

One click to cool a hot shard

BetterDB finds the Valkey shard doing all the work, names the keys behind it, plans the smallest slot move that fixes it, and runs it with Valkey 9's atomic slot migration.

The five steps, with the numbers from a run on a three-primary Valkey 9.1 cluster.

Rebalancing by hand means four hard questions

Moving slots off a hot node is easy to describe. Valkey gives you none of the answers you need to do it directly:

Which shard is hot?

INFO shows CPU per node, but not whether it is client traffic or a background job, and not which slots it comes from.

Why is it hot?

If one key carries the load, moving slots just moves the problem to another node.

Which slots, and where?

Move too few and nothing changes. Move the wrong ones and you overload the target.

How do you move them safely?

SETSLOT IMPORTING, SETSLOT MIGRATING, GETKEYSINSLOT and MIGRATE in a loop, then SETSLOT NODE on both sides - per slot. 2,000 slots is around 13,000 commands, and a script that dies halfway leaves slots stuck mid-move.

How BetterDB answers them

01Detect

BetterDB turns CLUSTER SLOT-STATS (Valkey 8.0+) into per-slot CPU rates and adds them up per primary. A shard is hot when it holds 2× the cluster median for 60 seconds and is above 10% of a core; it clears below 1.5×, so the alert never flaps. Network bytes are shown but never trigger it, because they include the replication stream.

02Explain

With an LFU eviction policy, BetterDB reads OBJECT FREQ for keys in the hottest slots and puts the top keys in the event. If one slot carries 20% or more of the shard’s CPU, it stays put, and when that is most of the load BetterDB says rebalancing will not help and suggests key-level fixes instead.

03Plan

The planner moves contiguous slot ranges with the fewest keys for the CPU they carry to the coldest healthy primaries - as few targets as possible, at most four - and keeps every target under 1.25× the projected median. You see the projected CPU of every shard before and after, plus warnings about replicas, memory and fork cost.

04Run

On Valkey 9.0+, an admin clicks Run this plan. BetterDB checks the live cluster again and sends one CLUSTER MIGRATESLOTS covering the whole plan. Valkey streams the slots on the server and switches ownership atomically: every range moves or none do, and a running move can be cancelled.

166 ms, and within a few percent of the prediction

A three-primary Valkey 9.1 cluster with one shard pushed hard. The plan moved slots 13–2170 (2,158 slots, about 40% of the hot shard's CPU) to the coldest shard, projecting 1.24× the median. BetterDB measured 1.27× afterwards, and the alert resolved by itself.

BeforeAfter
Hot shard CPU vs median4.4×1.27×
Hot shard slots5,4613,303
Target shard slots5,4617,619

Built to be hard to misuse

Moving slots is the most consequential thing BetterDB can do to a cluster, so the button comes with guardrails:

Off by default

Nothing runs unless the monitor starts with BETTERDB_SLOT_MIGRATION=true, and BetterDB never starts a move on its own.

Admins only, always audited

Every run and cancel is written to the activity log with the hot shard as the target.

The plan you saw is the plan that runs

The request carries the moves the dialog showed. If the plan changed in the meantime, BetterDB refuses and shows the new one.

Checked again before sending

A fresh CLUSTER NODES must show the hot shard still owning every range, every node healthy, and no migration running anywhere.

Sent once

No retries and no double runs. If the server refuses - for example over ACL permissions - you see its own message.

Every migration watched

Moves started by valkey-cli, operators or scripts are tracked too, and a stuck or failed migration raises its own event.

What you need

Detection

Valkey 8.0+ with cluster-slot-stats-enabled yes, and at least three slot-owning primaries.

Hot key names

An LFU eviction policy (allkeys-lfu or volatile-lfu) and +cluster|getkeysinslot +object|freq for the monitoring user.

One-click moves

Valkey 9.0+, BETTERDB_SLOT_MIGRATION=true, and +cluster|migrateslots +cluster|cancelslotmigrations for the monitoring user.

Full reference in the anomaly detection docs. The deep dive is on the blog.

FAQ

What is a hot shard in a Valkey cluster?

A hot shard is a primary doing far more work than the others - in BetterDB’s terms, CPU at 2× the cluster median or more, held for at least 60 seconds. Latency rises for every key on that node, not just the busy ones, while the rest of the cluster sits idle.

How does BetterDB know which slots to move?

It reads per-slot CPU from CLUSTER SLOT-STATS on every poll, skips any slot that alone carries 20% or more of the shard’s CPU, and picks contiguous ranges with the fewest keys for the CPU they carry, so the move copies as little data as possible. Each target is checked against 1.25× the projected median using the real ranges, not averages.

What is atomic slot migration in Valkey 9?

Valkey 9.0 added CLUSTER MIGRATESLOTS. You send one command to the source naming the slot ranges and the target; Valkey snapshots the slots, streams them and the writes that arrive meanwhile, then pauses writes on those slots for a moment and switches ownership in one step. Either every range in the command moves or none do, and CLUSTER CANCELSLOTMIGRATIONS stops a move in progress.

Will BetterDB move slots on its own?

No. The feature is off unless the monitor runs with BETTERDB_SLOT_MIGRATION=true, only admins can run a plan, and BetterDB re-checks the plan against the live cluster before it sends anything. Without the flag you still get detection, the plan and the exact command to run yourself.

What if one hot key is the problem?

Then moving slots will not help, because a key cannot be split across shards. BetterDB says so instead of producing a plan, names the key when LFU is on, and suggests key-level fixes such as client-side caching, reads from replicas or splitting the key.

Does it work on ElastiCache and other managed services?

Detection and planning work wherever CLUSTER SLOT-STATS is available. Managed services such as ElastiCache do not allow the slot migration commands, so BetterDB shows the plan with the slot ranges to apply through your provider’s own resharding instead of a Run button. Some providers also block SLOT-STATS, and without it there is no per-slot CPU to detect from.

Related: cluster monitoring · hot keys · anomaly detection

Point it at a Valkey cluster and watch the shards

docker run -d -p 3001:3001 betterdb/monitor:latest

Then open http://localhost:3001 - see the Docker guide.

Want a hand setting it up, or have a cluster that keeps running hot? Email us at support@betterdb.com.

Ready to get started?

Start monitoring in minutes - no infrastructure to maintain. Team collaboration, agent-based monitoring for private databases, and more. Or self-host - open source core, zero lock-in.