CLUSTER-SLOT-STATS(3valkey)

πŸ“¦
version 9.0.6 Β· 2 versions
, in fedora 44

πŸ’… CLUSTER-SLOT-STATS πŸ’…

okay so bestie, welcome to the Valkey Command Manual β€” this is cluster-slot-stats(3valkey) and it's literally the vibe check for your cluster slots πŸ¦‹


✨ NAME ✨

cluster-slot-stats β€” returns an array of slot usage statistics for slots assigned to the current node. fr fr that's the whole thing πŸ’–


🌸 SYNOPSIS 🌸

CLUSTER SLOT-STATS SLOTSRANGE start-slot end-slot
CLUSTER SLOT-STATS ORDERBY metric [LIMIT limit] [ASC | DESC]

two whole moods, pick your fighter πŸ‘‘


πŸ’« DESCRIPTION πŸ’«

So this bad boy returns an array of slot usage statistics for slots assigned to the current shard. It's giving main character energy for Valkey Cluster girlies who wanna:

  • assess general slot usage trends πŸ‘€
  • identify hot / cold slots πŸ”₯🧊
  • migrate slots for a balanced cluster workload βš–οΈ
  • and/or re-write application logic to better utilize slots ✍️

The following statistics are supported, and yes they all ate:

  • key-count – Number of keys residing in a given slot. πŸ—οΈ
  • cpu-usec – Amount of CPU time (in microseconds) spent on a given slot. ⏱️
  • network-bytes-in – Amount of network ingress (in bytes) received for given slot. πŸ“₯
  • network-bytes-out – Amount of network egress (in bytes) sent out for given slot. πŸ“€

πŸŽ€ OPTIONS πŸŽ€

  • ORDERBY β€” Returns an ordered slot statistics based on the specified statistic and sub-arguments to identify hot / cold slots across the cluster. Either ASC or DESC modifiers can be used. In the event of a tie in the stats, ascending slot number is used as a tie breaker. no cap, that's the rule πŸ’…
  • SLOTSRANGE β€” Returns slot statistics based on the slots range provided for pagination. The range is inclusive (both ends count, bestie). The response is ordered in ascending slot number. πŸ“ˆ

🫢 REPLY 🫢

valkey-protocol(7) Array reply: nested list of slot usage statistics. it's nested. it's an array. it's iconic. ✨


πŸ”₯ COMPLEXITY πŸ”₯

  • O(N) where N is the total number of slots based on arguments.
  • O(N*log(N)) with ORDERBY subcommand.

so basically ORDERBY is the one doing extra cardio πŸƒβ™€οΈ


πŸ‘‘ ACL CATEGORIES πŸ‘‘

@slow β€” yeah she's not fast, she's thorough, respect it πŸ’œ


⭐ HISTORY ⭐

  • Available since: 8.0.0 πŸŽ‚

🌈 EXAMPLES 🌈

Response in RESP2 πŸ“

For ORDERBY:

> CLUSTER SLOT-STATS ORDERBY KEY-COUNT LIMIT 2 DESC
1) 1) (integer) 12426
   2) 1) "key-count"
      2) (integer) 45
      3) "cpu-usec"
      4) (integer) 0
      5) "network-bytes-in"
      6) (integer) 0
      7) "network-bytes-out"
      8) (integer) 0
2) 1) (integer) 13902
   2) 1) "key-count"
      2) (integer) 20
      3) "cpu-usec"
      4) (integer) 0
      5) "network-bytes-in"
      6) (integer) 0
      7) "network-bytes-out"
      8) (integer) 0

For SLOTSRANGE:

> CLUSTER SLOT-STATS SLOTSRANGE 0 1
1) 1) (integer) 0
   2) 1) "key-count"
      2) (integer) 0
      3) "cpu-usec"
      4) (integer) 0
      5) "network-bytes-in"
      6) (integer) 0
      7) "network-bytes-out"
      8) (integer) 0
2) 1) (integer) 1
   2) 1) "key-count"
      2) (integer) 0
      3) "cpu-usec"
      4) (integer) 0
      5) "network-bytes-in"
      6) (integer) 0
      7) "network-bytes-out"
      8) (integer) 0

Response in RESP3 🧚

For ORDERBY:

> CLUSTER SLOT-STATS ORDERBY KEY-COUNT LIMIT 2 DESC
1) 1) (integer) 12426
   2) 1# "key-count" => (integer) 45
      2# "cpu-usec" => (integer) 0
      3# "network-bytes-in" => (integer) 0
      4# "network-bytes-out" => (integer) 0
2) 1) (integer) 13902
   2) 1# "key-count" => (integer) 20
      2# "cpu-usec" => (integer) 0
      3# "network-bytes-in" => (integer) 0
      4# "network-bytes-out" => (integer) 0

For SLOTSRANGE:

> CLUSTER SLOT-STATS SLOTSRANGE 0 1
1) 1) (integer) 0
   2) 1# "key-count" => (integer) 0
      2# "cpu-usec" => (integer) 0
      3# "network-bytes-in" => (integer) 0
      4# "network-bytes-out" => (integer) 0
2) 1) (integer) 1
   2) 1# "key-count" => (integer) 0
      2# "cpu-usec" => (integer) 0
      3# "network-bytes-in" => (integer) 0
      4# "network-bytes-out" => (integer) 0
not me noticing every single one of those counters is 0 in the examples 😭 it's a demo, bestie, breathe.

πŸ’– SEE ALSO πŸ’–

the whole friend group, obviously πŸ«‚


and that's the whole page, periodt πŸ’… this lil masterpiece is from version 9.0.0, dated 2025-10-21, and yeah it lives in the CLUSTER-SLOT-STATS(3valkey) section of the manual. go slay some slots, bestie πŸ¦‹βœ¨

πŸ“¦ where this page comes from