Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CLUSTER SLOT-STATS document. #150

Merged
merged 11 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -3095,6 +3095,87 @@
"nondeterministic_output"
]
},
"CLUSTER SLOT-STATS": {
madolson marked this conversation as resolved.
Show resolved Hide resolved
"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",
Expand Down
42 changes: 42 additions & 0 deletions commands/cluster-slot-stats.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
`CLUSTER SLOT-STATS` returns an array of slot usage statistics for slots assigned to the current shard.
madolson marked this conversation as resolved.
Show resolved Hide resolved
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:
madolson marked this conversation as resolved.
Show resolved Hide resolved
* key-count
madolson marked this conversation as resolved.
Show resolved Hide resolved

## Supported arguments
madolson marked this conversation as resolved.
Show resolved Hide resolved
There exist two mutually exclusive arguments, namely;
madolson marked this conversation as resolved.
Show resolved Hide resolved

### 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
```