From 8ec5cbc54891b4b85608abb333d5ce0052c97719 Mon Sep 17 00:00:00 2001 From: Kyle Kim Date: Tue, 25 Jun 2024 22:02:25 +0000 Subject: [PATCH] Add CLUSTER SLOT-STATS document. - Valkey PR link; https://github.com/valkey-io/valkey/pull/351. Signed-off-by: Kyle Kim --- commands.json | 81 ++++++++++++++++++ commands/cluster-slot-stats.md | 42 +++++++++ .../__pycache__/command_syntax.cpython-38.pyc | Bin 0 -> 7089 bytes 3 files changed, 123 insertions(+) create mode 100644 commands/cluster-slot-stats.md create mode 100644 utils/__pycache__/command_syntax.cpython-38.pyc diff --git a/commands.json b/commands.json index c95dc374..881c4e71 100644 --- a/commands.json +++ b/commands.json @@ -3095,6 +3095,87 @@ "nondeterministic_output" ] }, + "CLUSTER SLOT-STATS": { + "summary": "Returns an array of slot usage statistics for slots assigned to the current shard.", + "since": "8.0.0", + "group": "cluster", + "complexity": "O(N) where N is the total number of slots based on arguments. O(N log N) with ORDERBY subcommand.", + "history": [ + [ + "8.0.0", + "Initial release with key-count metric support." + ] + ], + "acl_categories": [ + "@slow" + ], + "arity": -4, + "command_flags": [ + "stale", + "loading" + ], + "hints": [ + "nondeterministic_output", + "request_policy:all_shards" + ], + "arguments": [ + { + "name": "filter", + "type": "oneof", + "arguments": [ + { + "token": "SLOTSRANGE", + "name": "slotsrange", + "type": "block", + "arguments": [ + { + "name": "start-slot", + "type": "integer" + }, + { + "name": "end-slot", + "type": "integer" + } + ] + }, + { + "token": "ORDERBY", + "name": "orderby", + "type": "block", + "arguments": [ + { + "name": "metric", + "type": "string" + }, + { + "token": "LIMIT", + "name": "limit", + "type": "integer", + "optional": true + }, + { + "name": "order", + "type": "oneof", + "optional": true, + "arguments": [ + { + "name": "asc", + "type": "pure-token", + "token": "ASC" + }, + { + "name": "desc", + "type": "pure-token", + "token": "DESC" + } + ] + } + ] + } + ] + } + ] + }, "COMMAND": { "summary": "Returns detailed information about all commands.", "since": "2.8.13", diff --git a/commands/cluster-slot-stats.md b/commands/cluster-slot-stats.md new file mode 100644 index 00000000..4b667814 --- /dev/null +++ b/commands/cluster-slot-stats.md @@ -0,0 +1,42 @@ +`CLUSTER SLOT-STATS` returns an array of slot usage statistics for slots assigned to the current shard. +The command is suitable for Valkey Cluster users aiming to 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. + +As of now, the following metrics are supported: +* key-count + +## Supported arguments +There exist two mutually exclusive arguments, namely; + +### SLOTSRANGE +Returns slot statistics based on the slots range provided. +The `SLOTSRANGE` argument allows for request pagination. + +``` +> CLUSTER SLOT-STATS SLOTSRANGE 0 2 +> 1) (integer) 0 +> 2) 1) "key-count" +> 2) (integer) 0 +> 3) (integer) 1 +> 4) 1) "key-count" +> 2) (integer) 0 +> 5) (integer) 2 +> 6) 1) "key-count" +> 2) (integer) 0 +``` + +### ORDERBY +Orders slot statistics based on the provided metric. Right now, only `key-count` is available. +The `ORDERBY` argument allows for the user to identify hot / cold slots across the cluster. + +``` +> CLUSTER SLOT-STATS ORDERBY KEY-COUNT LIMIT 3 DESC +> 1) (integer) 12426 +> 2) 1) "key-count" +> 2) (integer) 45 +> 3) (integer) 13902 +> 4) 1) "key-count" +> 2) (integer) 20 +> 5) (integer) 2704 +> 6) 1) "key-count" +> 2) (integer) 11 +``` diff --git a/utils/__pycache__/command_syntax.cpython-38.pyc b/utils/__pycache__/command_syntax.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..398dc08e09088dc9ea949663a22589fbccce172a GIT binary patch literal 7089 zcmb7JOKcp;d9Ld2d9XQriXuho)jL|PInt8cmDfSMp_CO&%XSbbjz~M3QHa^rRL!W# zneI__b1AmT1c(HXJ}jbKgFQ$JmJ4_#ssS}!G+P{Rj$8A z)zDwFY6`Pzd91;OC34SsHK)sYQ9wB_3!=Ddyx{5=(%31AF}%lwEiEzriB+|wy)!OK zVnR%cDKY(t#hGrI5wmDHH_$RC&ZA|1pk+Z^K+EDl%aXV#E{V&Zm>HETs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