Crates.io | redis-keyspace-stats |
lib.rs | redis-keyspace-stats |
version | 0.5.4 |
source | src |
created_at | 2020-12-08 01:24:36.725521 |
updated_at | 2023-04-21 01:22:53.590563 |
description | Analyzes your Redis keyspace and returns statistics about it |
homepage | |
repository | https://github.com/scott113341/redis-keyspace-stats |
max_upload_size | |
id | 320676 |
size | 72,174 |
This program analyzes your Redis keyspace and returns statistics about it. It's somewhat flexible. Usually, you'll provide glob-style patterns to group keys into bins.
This tool is under development, and some obviously useful features are not yet implemented.
Sampling modes:
Statistics:
Output formats:
Redis support:
rediss://
connection strings)redis://host:port/db
)-n 100
before running more comprehensive analysis.--sample=all
mode with care; the -n
option is ignored and ALL keys will be enumerated with
SCAN
For now, there are no published binaries of this tool.
cargo install redis-keyspace-stats
to download + compile the binaryInvoking the CLI with -h
(or --help
, which is more verbose) will print documentation:
$ redis-keyspace-stats -h
Usage: redis-keyspace-stats [OPTIONS] [PATTERNS]...
Arguments:
[PATTERNS]... Glob-style patterns to group keys together
Options:
--sample <SAMPLE_MODE> [default: random] [possible values: all, random]
-n, --samples <N_SAMPLES> Ignored when --sample=all is specified [default: 100]
--batch-size <BATCH_SIZE> [default: 100]
--batch-sleep-ms <BATCH_SLEEP_MS> [default: 100]
--stats <STATS> [default: memory,ttl] [possible values: memory, ttl, type]
-o, --out <OUTPUT_MODE> [default: table] [possible values: table]
--url <URL> [default: redis://127.0.0.1]
-h, --help Print help
-V, --version Print version
Let's get some quick memory + TTL stats, sampling 50 keys:
$ redis-keyspace-stats --url $REDIS_URL -n 50
Sampled 50 of 128 keys in db0
βββββββββββ¬βββββββββββββββββ¬βββββββββββββββββββββ¬βββββββββββββββββββββββββ¬ββββββββββββββββββ
β Pattern β Keys β Example keys β Memory β TTL β
βββββββββββΌβββββββββββββββββΌβββββββββββββββββββββΌβββββββββββββββββββββββββΌββββββββββββββββββ€
β * β 50 counted β company:121#memes β 360.77 kB (sum) β 54.00% have TTL β
β β 128 est. total β user:79#memes β 923.57 kB (est. total) β 2m 47s (p50) β
β β β user:8#memes β 7.75 kB (p50) β 3m 57s (p90) β
β β β user:92#friends β 11.9 kB (p90) β 4m 13s (p99) β
β β β company:84#friends β 12.87 kB (p99) β β
βββββββββββ΄βββββββββββββββββ΄βββββββββββββββββββββ΄βββββββββββββββββββββββββ΄ββββββββββββββββββ
Using what's showing in the "Example keys" column, let's write a few glob-style patterns to bin keys together:
$ redis-keyspace-stats --url $REDIS_URL -n 50 'user:*#messages' 'user:?#*' 'company:*'
Sampled 50 of 128 keys in db0
βββββββββββββββββββ¬ββββββββββββββββ¬βββββββββββββββββββββ¬βββββββββββββββββββββββββ¬βββββββββββββββββββ
β Pattern β Keys β Example keys β Memory β TTL β
βββββββββββββββββββΌββββββββββββββββΌβββββββββββββββββββββΌβββββββββββββββββββββββββΌβββββββββββββββββββ€
β user:*#messages β 8 counted β user:27#messages β 30.27 kB (sum) β 37.50% have TTL β
β β 20 est. total β user:34#messages β 77.5 kB (est. total) β 1m 30s (p50) β
β β β user:13#messages β 3.4 kB (p50) β 3m 25s (p90) β
β β β user:58#messages β 6.22 kB (p90) β 3m 51s (p99) β
β β β user:60#messages β 6.22 kB (p99) β β
βββββββββββββββββββΌββββββββββββββββΌβββββββββββββββββββββΌβββββββββββββββββββββββββΌβββββββββββββββββββ€
β user:?#* β 2 counted β user:3#friends β 1.25 kB (sum) β 100.00% have TTL β
β β 5 est. total β user:8#memes β 3.19 kB (est. total) β 1m 52s (p50) β
β β β β 624 B (p50) β 2m 39s (p90) β
β β β β 822.4 B (p90) β 2m 50s (p99) β
β β β β 867.04 B (p99) β β
βββββββββββββββββββΌββββββββββββββββΌβββββββββββββββββββββΌβββββββββββββββββββββββββΌβββββββββββββββββββ€
β company:* β 24 counted β company:1#messages β 162.13 kB (sum) β 45.83% have TTL β
β β 61 est. total β company:75#memes β 415.05 kB (est. total) β 2m 51s (p50) β
β β β company:10#friends β 7.24 kB (p50) β 3m 58s (p90) β
β β β company:69#memes β 11.85 kB (p90) β 4m 2s (p99) β
β β β company:6#memes β 12.64 kB (p99) β β
βββββββββββββββββββΌββββββββββββββββΌβββββββββββββββββββββΌβββββββββββββββββββββββββΌβββββββββββββββββββ€
β * β 16 counted β user:123#memes β 149.02 kB (sum) β 31.25% have TTL β
β β 41 est. total β user:71#friends β 381.5 kB (est. total) β 2m 10s (p50) β
β β β user:25#friends β 10.05 kB (p50) β 2m 59s (p90) β
β β β user:86#memes β 12.86 kB (p90) β 3m 4s (p99) β
β β β user:110#friends β 13.29 kB (p99) β β
βββββββββββββββββββ΄ββββββββββββββββ΄βββββββββββββββββββββ΄βββββββββββββββββββββββββ΄βββββββββββββββββββ
Note that the first pattern that matches a key will determine the group.
RKS_SEED_FAKE_DATA=true cargo run -- --sample=all 'company:*'
redis-cli
binary and running monitor
can be useful for debuggingversion
in Cargo.toml
cargo test
cargo publish