From 65d2006db1941bd2e14f0e886a0a48670a10379f Mon Sep 17 00:00:00 2001 From: Kyle Kim Date: Tue, 25 Jun 2024 22:02:25 +0000 Subject: [PATCH 01/11] 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 ++++++++++++++++++ 2 files changed, 123 insertions(+) create mode 100644 commands/cluster-slot-stats.md 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 +``` From c4f077579a1dc57a28e16a0b10c99380aea9c691 Mon Sep 17 00:00:00 2001 From: Kyle Kim Date: Wed, 26 Jun 2024 04:52:56 +0000 Subject: [PATCH 02/11] Minor revision. - Removed commands.json changes. - Added ordering invariance within the markdown. Signed-off-by: Kyle Kim --- commands.json | 81 ---------------------------------- commands/cluster-slot-stats.md | 42 +++++++++--------- 2 files changed, 22 insertions(+), 101 deletions(-) diff --git a/commands.json b/commands.json index 881c4e71..c95dc374 100644 --- a/commands.json +++ b/commands.json @@ -3095,87 +3095,6 @@ "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 index 4b667814..081c874e 100644 --- a/commands/cluster-slot-stats.md +++ b/commands/cluster-slot-stats.md @@ -8,35 +8,37 @@ As of now, the following metrics are supported: There exist two mutually exclusive arguments, namely; ### SLOTSRANGE -Returns slot statistics based on the slots range provided. +Returns slot statistics based on the slots range provided. The range is inclusive. The `SLOTSRANGE` argument allows for request pagination. +The response is ordered in ascending slot number. ``` > 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 +1) 1) (integer) 0 + 2) 1) "key-count" + 2) (integer) 0 +2) 1) (integer) 1 + 2) 1) "key-count" + 2) (integer) 0 +3) 1) (integer) 2 + 2) 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. +The response is ordered based on sort result. ``` > 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 -``` +1) 1) (integer) 12426 + 2) 1) "key-count" + 2) (integer) 45 +2) 1) (integer) 13902 + 2) 1) "key-count" + 2) (integer) 20 +3) 1) (integer) 2704 + 2) 1) "key-count" + 2) (integer) 11 +``` \ No newline at end of file From 3625f09457f2b86976c7b7401447bdce1439698d Mon Sep 17 00:00:00 2001 From: Kyle Kim Date: Thu, 27 Jun 2024 23:51:04 +0000 Subject: [PATCH 03/11] Minor revision. - Added RESP3 response. Signed-off-by: Kyle Kim --- commands/cluster-slot-stats.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/commands/cluster-slot-stats.md b/commands/cluster-slot-stats.md index 081c874e..c1a18434 100644 --- a/commands/cluster-slot-stats.md +++ b/commands/cluster-slot-stats.md @@ -12,6 +12,7 @@ Returns slot statistics based on the slots range provided. The range is inclusiv The `SLOTSRANGE` argument allows for request pagination. The response is ordered in ascending slot number. +##### Response in RESP2 ``` > CLUSTER SLOT-STATS SLOTSRANGE 0 2 1) 1) (integer) 0 @@ -25,11 +26,24 @@ The response is ordered in ascending slot number. 2) (integer) 0 ``` +##### Response in RESP3 +``` +> CLUSTER SLOT-STATS SLOTSRANGE 0 2 +1) 1) (integer) 0 + 2) 1# "key-count" => (integer) 0 +2) 1) (integer) 1 + 2) 1# "key-count" => (integer) 0 +3) 1) (integer) 2 + 2) 1# "key-count" => (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. The response is ordered based on sort result. + +##### Response in RESP2 ``` > CLUSTER SLOT-STATS ORDERBY KEY-COUNT LIMIT 3 DESC 1) 1) (integer) 12426 @@ -41,4 +55,15 @@ The response is ordered based on sort result. 3) 1) (integer) 2704 2) 1) "key-count" 2) (integer) 11 +``` + +##### Response in RESP3 +``` +> CLUSTER SLOT-STATS ORDERBY KEY-COUNT LIMIT 3 DESC +1) 1) (integer) 12426 + 2) 1# "key-count" => (integer) 45 +2) 1) (integer) 13902 + 2) 1# "key-count" => (integer) 20 +3) 1) (integer) 2704 + 2) 1# "key-count" => (integer) 11 ``` \ No newline at end of file From 3c6a17eb525278221af8b11e9d3ba0ddb395f019 Mon Sep 17 00:00:00 2001 From: Kyle Kim Date: Fri, 2 Aug 2024 02:52:30 +0000 Subject: [PATCH 04/11] Minor revision. - Added cpu, network-bytes-in and network-bytes-out metrics. - Added a tie breaker condition for ORDERBY argument. Signed-off-by: Kyle Kim --- commands/cluster-slot-stats.md | 62 +++++++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 16 deletions(-) diff --git a/commands/cluster-slot-stats.md b/commands/cluster-slot-stats.md index c1a18434..359545fc 100644 --- a/commands/cluster-slot-stats.md +++ b/commands/cluster-slot-stats.md @@ -2,7 +2,10 @@ 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 +* `key-count` - Number of keys residing in a given slot. +* `cpu-usec` - Amount of cpu time (in micro-seconds) spent on a given slot. +* `network-bytes-in` - Amount of network ingress (in bytes) spent on a given slot. +* `network-bytes-out` - Amount of network egress (in bytes) spent on a given slot. ## Supported arguments There exist two mutually exclusive arguments, namely; @@ -14,56 +17,83 @@ The response is ordered in ascending slot number. ##### Response in RESP2 ``` -> CLUSTER SLOT-STATS SLOTSRANGE 0 2 +> 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) 1) (integer) 2 - 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 ``` -> CLUSTER SLOT-STATS SLOTSRANGE 0 2 +> 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 -3) 1) (integer) 2 - 2) 1# "key-count" => (integer) 0 + 2# "cpu-usec" => (integer) 0 + 3# "network-bytes-in" => (integer) 0 + 4# "network-bytes-out" => (integer) 0 ``` ### ORDERBY -Orders slot statistics based on the provided metric. Right now, only `key-count` is available. +Orders slot statistics based on the provided metric. The `ORDERBY` argument allows for the user to identify hot / cold slots across the cluster. The response is ordered based on sort result. +In the event of a tie in the provided metric value, ascending slot number is used as a tie breaker. ##### Response in RESP2 ``` -> CLUSTER SLOT-STATS ORDERBY KEY-COUNT LIMIT 3 DESC +> 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) 1) (integer) 2704 - 2) 1) "key-count" - 2) (integer) 11 + 3) "cpu-usec" + 4) (integer) 0 + 5) "network-bytes-in" + 6) (integer) 0 + 7) "network-bytes-out" + 8) (integer) 0 ``` ##### Response in RESP3 ``` -> CLUSTER SLOT-STATS ORDERBY KEY-COUNT LIMIT 3 DESC +> 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 -3) 1) (integer) 2704 - 2) 1# "key-count" => (integer) 11 + 2# "cpu-usec" => (integer) 0 + 3# "network-bytes-in" => (integer) 0 + 4# "network-bytes-out" => (integer) 0 ``` \ No newline at end of file From 351403799da0d4ebc4c1196f61577e54252dd7b2 Mon Sep 17 00:00:00 2001 From: Madelyn Olson Date: Wed, 7 Aug 2024 16:28:20 -0700 Subject: [PATCH 05/11] Update commands/cluster-slot-stats.md Signed-off-by: Madelyn Olson --- commands/cluster-slot-stats.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/cluster-slot-stats.md b/commands/cluster-slot-stats.md index 359545fc..107f1706 100644 --- a/commands/cluster-slot-stats.md +++ b/commands/cluster-slot-stats.md @@ -4,8 +4,8 @@ The command is suitable for Valkey Cluster users aiming to assess general slot u As of now, the following metrics are supported: * `key-count` - Number of keys residing in a given slot. * `cpu-usec` - Amount of cpu time (in micro-seconds) spent on a given slot. -* `network-bytes-in` - Amount of network ingress (in bytes) spent on a given slot. -* `network-bytes-out` - Amount of network egress (in bytes) 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. ## Supported arguments There exist two mutually exclusive arguments, namely; From cfcb41dd30a532bdbd6a4996151246eb58dd74f6 Mon Sep 17 00:00:00 2001 From: Kyle Kim Date: Wed, 23 Oct 2024 19:35:32 +0000 Subject: [PATCH 06/11] Minor revision. - Consolidated metrics/statistics wording into statistics. - Remove verbosity. Signed-off-by: Kyle Kim --- commands/cluster-slot-stats.md | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/commands/cluster-slot-stats.md b/commands/cluster-slot-stats.md index 107f1706..77b86be3 100644 --- a/commands/cluster-slot-stats.md +++ b/commands/cluster-slot-stats.md @@ -1,14 +1,14 @@ `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: +The following statistics are supported: * `key-count` - Number of keys residing in a given slot. * `cpu-usec` - Amount of cpu time (in micro-seconds) 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. -## Supported arguments -There exist two mutually exclusive arguments, namely; +## Supported filtering and ordering arguments +There exist two mutually exclusive arguments for controlling the output, namely; ### SLOTSRANGE Returns slot statistics based on the slots range provided. The range is inclusive. @@ -54,11 +54,7 @@ The response is ordered in ascending slot number. ``` ### ORDERBY -Orders slot statistics based on the provided metric. -The `ORDERBY` argument allows for the user to identify hot / cold slots across the cluster. -The response is ordered based on sort result. -In the event of a tie in the provided metric value, ascending slot number is used as a tie breaker. - +The `ORDERBY` argument returns an ordered slot statistics based on the specified statistic and sub-arguments to identify hot / cold slots across the cluster. In the event of a tie in the stats, ascending slot number is used as a tie breaker. ##### Response in RESP2 ``` From 270e004ed80d3c2745e95722b322e65a167d16db Mon Sep 17 00:00:00 2001 From: Kyle Kim Date: Sat, 16 Nov 2024 19:07:37 -0500 Subject: [PATCH 07/11] Major revision. - Re-order sections to fit existing standards; OPTIONS and EXAMPLES. Signed-off-by: Kyle Kim --- commands/cluster-slot-stats.md | 77 ++++++++++++++++------------------ 1 file changed, 36 insertions(+), 41 deletions(-) diff --git a/commands/cluster-slot-stats.md b/commands/cluster-slot-stats.md index 77b86be3..39ed862d 100644 --- a/commands/cluster-slot-stats.md +++ b/commands/cluster-slot-stats.md @@ -2,34 +2,35 @@ 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. The following statistics are supported: -* `key-count` - Number of keys residing in a given slot. -* `cpu-usec` - Amount of cpu time (in micro-seconds) 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. -## Supported filtering and ordering arguments -There exist two mutually exclusive arguments for controlling the output, namely; +* `KEY-COUNT` -- Number of keys residing in a given slot. +* `CPU-USEC` *micro-seconds* -- Amount of cpu time (in micro-seconds) spent on a given slot. +* `NETWORK-BYTES-IN` *bytes* -- Amount of network ingress (in bytes) received for given slot. +* `NETWORK-BYTES-OUT` *bytes* -- Amount of network egress (in bytes) sent out for given slot. -### SLOTSRANGE -Returns slot statistics based on the slots range provided. The range is inclusive. -The `SLOTSRANGE` argument allows for request pagination. -The response is ordered in ascending slot number. +## Options + +* `ORDERBY` -- Returns an ordered slot statistics based on the specified statistic and sub-arguments to identify hot / cold slots across the cluster. In the event of a tie in the stats, ascending slot number is used as a tie breaker. +* `SLOTSRANGE` -- Returns slot statistics based on the slots range provided for pagination. The range is inclusive. The response is ordered in ascending slot number. + +## Examples + +### Response in RESP2 -##### Response in RESP2 ``` -> CLUSTER SLOT-STATS SLOTSRANGE 0 1 -1) 1) (integer) 0 +> CLUSTER SLOT-STATS ORDERBY KEY-COUNT LIMIT 2 DESC +1) 1) (integer) 12426 2) 1) "key-count" - 2) (integer) 0 + 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) 1 +2) 1) (integer) 13902 2) 1) "key-count" - 2) (integer) 0 + 2) (integer) 20 3) "cpu-usec" 4) (integer) 0 5) "network-bytes-in" @@ -37,40 +38,20 @@ The response is ordered in ascending slot number. 7) "network-bytes-out" 8) (integer) 0 ``` - -##### Response in RESP3 ``` > 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 -``` - -### ORDERBY -The `ORDERBY` argument returns an ordered slot statistics based on the specified statistic and sub-arguments to identify hot / cold slots across the cluster. In the event of a tie in the stats, ascending slot number is used as a tie breaker. - -##### Response in RESP2 -``` -> CLUSTER SLOT-STATS ORDERBY KEY-COUNT LIMIT 2 DESC -1) 1) (integer) 12426 2) 1) "key-count" - 2) (integer) 45 + 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) 13902 +2) 1) (integer) 1 2) 1) "key-count" - 2) (integer) 20 + 2) (integer) 0 3) "cpu-usec" 4) (integer) 0 5) "network-bytes-in" @@ -79,7 +60,8 @@ The `ORDERBY` argument returns an ordered slot statistics based on the specified 8) (integer) 0 ``` -##### Response in RESP3 +### Response in RESP3 + ``` > CLUSTER SLOT-STATS ORDERBY KEY-COUNT LIMIT 2 DESC 1) 1) (integer) 12426 @@ -92,4 +74,17 @@ The `ORDERBY` argument returns an ordered slot statistics based on the specified 2# "cpu-usec" => (integer) 0 3# "network-bytes-in" => (integer) 0 4# "network-bytes-out" => (integer) 0 -``` \ No newline at end of file +``` +``` +> 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 +``` From 5f3a1cf5daa5dd1cf6bf8fd2d4b9f5a10275edf6 Mon Sep 17 00:00:00 2001 From: Kyle Kim Date: Sun, 17 Nov 2024 16:08:46 -0500 Subject: [PATCH 08/11] Minor revision. - Updated stat type to lower case. Signed-off-by: Kyle Kim --- commands/cluster-slot-stats.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/commands/cluster-slot-stats.md b/commands/cluster-slot-stats.md index 39ed862d..7f2a9f79 100644 --- a/commands/cluster-slot-stats.md +++ b/commands/cluster-slot-stats.md @@ -3,10 +3,10 @@ The command is suitable for Valkey Cluster users aiming to assess general slot u The following statistics are supported: -* `KEY-COUNT` -- Number of keys residing in a given slot. -* `CPU-USEC` *micro-seconds* -- Amount of cpu time (in micro-seconds) spent on a given slot. -* `NETWORK-BYTES-IN` *bytes* -- Amount of network ingress (in bytes) received for given slot. -* `NETWORK-BYTES-OUT` *bytes* -- Amount of network egress (in bytes) sent out for given slot. +* `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 From f610b673709c8e28c4d0d2b66dd07e13ae81c80f Mon Sep 17 00:00:00 2001 From: Madelyn Olson Date: Sun, 17 Nov 2024 19:29:25 -0800 Subject: [PATCH 09/11] Update commands/cluster-slot-stats.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Viktor Söderqvist Signed-off-by: Madelyn Olson --- commands/cluster-slot-stats.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/cluster-slot-stats.md b/commands/cluster-slot-stats.md index 7f2a9f79..0d436830 100644 --- a/commands/cluster-slot-stats.md +++ b/commands/cluster-slot-stats.md @@ -1,4 +1,4 @@ -`CLUSTER SLOT-STATS` returns an array of slot usage statistics for slots assigned to the current shard. +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. The following statistics are supported: From 267f00e0363f0f981144fcc9a62789436e40a869 Mon Sep 17 00:00:00 2001 From: Kyle Kim Date: Mon, 18 Nov 2024 09:57:33 -0500 Subject: [PATCH 10/11] Minor revision. - Added ASC / DESC modifiers to the Option description. - Added header for each RESP response example. Signed-off-by: Kyle Kim --- commands/cluster-slot-stats.md | 8 +++++++- resp2_replies.json | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/commands/cluster-slot-stats.md b/commands/cluster-slot-stats.md index 0d436830..ea773a97 100644 --- a/commands/cluster-slot-stats.md +++ b/commands/cluster-slot-stats.md @@ -10,13 +10,14 @@ The following statistics are supported: ## Options -* `ORDERBY` -- Returns an ordered slot statistics based on the specified statistic and sub-arguments to identify hot / cold slots across the cluster. In the event of a tie in the stats, ascending slot number is used as a tie breaker. +* `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. * `SLOTSRANGE` -- Returns slot statistics based on the slots range provided for pagination. The range is inclusive. The response is ordered in ascending slot number. ## Examples ### Response in RESP2 +For `ORDERBY`: ``` > CLUSTER SLOT-STATS ORDERBY KEY-COUNT LIMIT 2 DESC 1) 1) (integer) 12426 @@ -38,6 +39,8 @@ The following statistics are supported: 7) "network-bytes-out" 8) (integer) 0 ``` + +For `SLOTSRANGE`: ``` > CLUSTER SLOT-STATS SLOTSRANGE 0 1 1) 1) (integer) 0 @@ -62,6 +65,7 @@ The following statistics are supported: ### Response in RESP3 +For `ORDERBY`: ``` > CLUSTER SLOT-STATS ORDERBY KEY-COUNT LIMIT 2 DESC 1) 1) (integer) 12426 @@ -75,6 +79,8 @@ The following statistics are supported: 3# "network-bytes-in" => (integer) 0 4# "network-bytes-out" => (integer) 0 ``` + +For `SLOTSRANGE`: ``` > CLUSTER SLOT-STATS SLOTSRANGE 0 1 1) 1) (integer) 0 diff --git a/resp2_replies.json b/resp2_replies.json index d57e8877..f93f0ac4 100644 --- a/resp2_replies.json +++ b/resp2_replies.json @@ -291,6 +291,9 @@ "CLUSTER SLOTS": [ "[Array reply](../topics/protocol.md#arrays): nested list of slot ranges with networking information." ], + "CLUSTER SLOT-STATS": [ + "[Array reply](../topics/protocol.md#arrays): nested list of slot usage statistics." + ], "COMMAND": [ "[Array reply](../topics/protocol.md#arrays): a nested list of command details. The order of the commands in the array is random." ], From 6012dc0222aeee4c108088d6af5783fed924baa9 Mon Sep 17 00:00:00 2001 From: Kyle Kim Date: Mon, 18 Nov 2024 15:39:03 -0500 Subject: [PATCH 11/11] Minor revision. - Added SLOT-STATS entry under resp2 and resp3_replies.json. Signed-off-by: Kyle Kim --- resp3_replies.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/resp3_replies.json b/resp3_replies.json index dfcd1145..fc62d1c3 100644 --- a/resp3_replies.json +++ b/resp3_replies.json @@ -291,6 +291,9 @@ "CLUSTER SLOTS": [ "[Array reply](../topics/protocol.md#arrays): nested list of slot ranges with networking information." ], + "CLUSTER SLOT-STATS": [ + "[Array reply](../topics/protocol.md#arrays): nested list of slot usage statistics." + ], "COMMAND": [ "[Array reply](../topics/protocol.md#arrays): a nested list of command details. The order of the commands in the array is random." ],