- 用法
-
CLUSTER SLOT-STATS 〈 SLOTSRANGE start-slot end-slot | ORDERBY metric [ LIMIT limit ] [ ASC | DESC ] 〉
- 复杂度
- O(N),其中 N 是基于参数的总槽数。使用 ORDERBY 子命令时为 O(N*log(N))。
- 始于
- 8.0.0
- ACL 类别
- @slow
key-count
-- 某个槽中键的数量。cpu-usec
-- 花费在某个槽上的 CPU 时间量(以微秒计)。network-bytes-in
-- 某个槽接收到的网络入站流量(以字节计)。network-bytes-out
-- 某个槽发送的网络出站流量(以字节计)。ORDERBY
-- 根据指定的统计信息和子参数返回有序的槽统计信息,以识别集群中的热/冷槽。可以使用ASC
或DESC
修饰符。如果统计数据出现平局,则使用升序槽号作为决胜条件。SLOTSRANGE
-- 根据为分页提供的槽范围返回槽统计信息。该范围是包含性的。响应按升序槽号排列。
返回分配给当前分片的槽使用情况统计数组。此命令适用于 Valkey 集群用户,旨在评估总体槽使用趋势、识别热/冷槽、迁移槽以平衡集群工作负载,和/或重写应用程序逻辑以更好地利用槽。
支持以下统计信息
选项
示例
RESP2 响应
对于 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
对于 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
RESP3 响应
对于 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
对于 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
RESP2/RESP3 回复
数组回复:槽使用情况统计的嵌套列表。