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: - ✅ Random sampling - 🚧 Random sampling of keys matching a pattern - 🚧 Scan all keys - 🚧 Scan all keys matching a pattern
Statistics: - ✅ Memory: total, 50/90/99th percentiles - ✅ TTL: percent with a TTL, 50/90/99th percentiles - 🚧 Data type breakdown
Output formats: - ✅ Summary pretty-printed table to STDOUT - 🚧 Summary CSV/TSV - 🚧 Summary HTML - 🚧 Raw data CSV/TSV
Redis support:
- ✅ Over TLS (rediss://
connection strings)
- 🚧 Clusters
- 🚧 Logical databases
-n 100
before running more comprehensive analysis.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
will print documentation:
``` $ redis-keyspace-stats -h redis-keyspace-stats 0.1.0
USAGE: redis-keyspace-stats [OPTIONS] [--] [patterns]...
ARGS:
FLAGS: -h, --help Prints help information -V, --version Prints version information
OPTIONS:
--batch-size
Let's get some quick memory + TTL stats, sampling 50 keys:
$ redis-keyspace-stats --url $REDIS_URL -n 50
+---------+-----------+---------------------+--------------+--------------------+--------------+-----------------+
| Pattern | Key count | Example keys | Memory (sum) | Memory (p50/90/99) | TTL (% with) | TTL (p50/90/99) |
+---------+-----------+---------------------+--------------+--------------------+--------------+-----------------+
| * | 50 | company:72#messages | 347.03 kB | 7.18 kB | 48.00% | 1m 51s |
| | | company:92#friends | | 11.64 kB | | 3m 14s |
| | | user:46#friends | | 12.68 kB | | 3m 39s |
| | | user:78#messages | | | | |
| | | company:3#memes | | | | |
+---------+-----------+---------------------+--------------+--------------------+--------------+-----------------+
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:*'
+-----------------+-----------+---------------------+--------------+--------------------+--------------+-----------------+
| Pattern | Key count | Example keys | Memory (sum) | Memory (p50/90/99) | TTL (% with) | TTL (p50/90/99) |
+-----------------+-----------+---------------------+--------------+--------------------+--------------+-----------------+
| user:*#messages | 8 | user:43#messages | 64.39 kB | 8.57 kB | 62.50% | 2m 16s |
| | | user:113#messages | | 11.71 kB | | 3m 12s |
| | | user:110#messages | | 12.4 kB | | 3m 16s |
| | | user:64#messages | | | | |
| | | user:124#messages | | | | |
+-----------------+-----------+---------------------+--------------+--------------------+--------------+-----------------+
| user:?#* | 2 | user:8#friends | 1.84 kB | 922 B | 0.00% | 0s |
| | | user:9#friends | | 962 B | | 0s |
| | | | | 971 B | | 0s |
+-----------------+-----------+---------------------+--------------+--------------------+--------------+-----------------+
| company:* | 25 | company:11#memes | 146.49 kB | 5.18 kB | 32.00% | 1m 56s |
| | | company:75#messages | | 10.56 kB | | 3m |
| | | company:110#friends | | 11.91 kB | | 3m 3s |
| | | company:32#memes | | | | |
| | | company:30#memes | | | | |
+-----------------+-----------+---------------------+--------------+--------------------+--------------+-----------------+
| * | 15 | user:117#memes | 106.29 kB | 7.17 kB | 33.33% | 56s |
| | | user:125#friends | | 11.73 kB | | 1m 16s |
| | | user:116#friends | | 12.46 kB | | 1m 16s |
| | | user:42#memes | | | | |
| | | user:92#friends | | | | |
+-----------------+-----------+---------------------+--------------+--------------------+--------------+-----------------+
Note that the first pattern that matches a key will determine the group.