A simple command-line tool for analyzing memory usage across keys in a Redis database.
Project description
redis-sizer
A simple command-line tool for analyzing memory usage across keys in a Redis database.
redis-sizer can help with the following problems:
- Optimize caching strategy.
- Gain insights into memory usage at different namespace levels.
- Identify which parts of your application consume the most memory.
Installation
Install via pip:
pip install redis-sizer
Usage
Run redis-sizer by specifying the Redis host along with any desired options:
redis-sizer [OPTIONS] HOST
Options:
--port: Port number [default: 6379]--db: DB number [default: 0]--password: Password [default: None]--socket-timeout: Socket timeout in seconds [default: 10]--socket-connect-timeout: Socket connect timeout in seconds [default: 10]--pattern: Pattern to filter keys [default: *]--sample-size: Number of keys to sample [default: None]--namespace-separator: Separator for key namespaces [default: :]--memory-unit: Memory unit for display in result table [default: B]--max-leaves: Maximum number of leaf keys to display per namespace [default: 5]--batch-size: Batch size for scanning and calculating memory usage [default: 1000]
Aggregating Memory Usage by Key Groups
Many applications using Redis adopt hierarchical key naming conventions.
For example, if your keys follow a colon-delimited format (e.g., users:logs:..., users:profiles:...), they can be visualized as a nested or tree-like structure:
DB
├── users:
│ ├── logs:
│ │ └── ...
│ └── profiles:
│ └── ...
...
redis-sizer leverages this hierarchical structure to aggregate and analyze memory usage, and displays aggregated statistics for each namespace level.
Considerations
- Since data can change during analysis, the final result may not accurately reflect the database’s state at the beginning of the process.
- For databases with large collections of keys, consider using the
--sample-sizeoption to balance processing time with accuracy. If--sample-sizeis not specified, redis-sizer will perform perform a full scan. - Increasing
--batch-sizecan reduce network overhead. However, this can increase the load on the Redis server without providing meaningful performance improvements and, in some cases, may even lead to server blocking. Adjust these values carefully based on your server’s capacity.
Redis Version Compatibility
- This tool relies on the Redis
MEMORY USAGEcommand, which has been available since version 4.0.0. - It has been tested and verified to work with Redis versions 4, 5, 6, and 7.
Dependencies
redis-sizer depends on:
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file redis_sizer-1.0.0.tar.gz.
File metadata
- Download URL: redis_sizer-1.0.0.tar.gz
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.23.0 CPython/3.11.4 Darwin/24.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a58183a627753a72667372d3d3d2bc294119e148326394dd56e1473f6860a69b
|
|
| MD5 |
de1016ec086aff732a3116b6d377cecd
|
|
| BLAKE2b-256 |
a3954a4e64a21a8f6a1d16ed21f189ba4a24dc2eadd83ed0ba2c44e433629352
|
File details
Details for the file redis_sizer-1.0.0-py3-none-any.whl.
File metadata
- Download URL: redis_sizer-1.0.0-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.23.0 CPython/3.11.4 Darwin/24.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a84a50acca311600de311e6706126b280fce8e8c9afd3d807946d7d6e6d05b96
|
|
| MD5 |
a33a487ee2c38d72dec3f992f2d3d16d
|
|
| BLAKE2b-256 |
e47e9dbe7c092f970a933f06bb30d4cfcbb5494d19124f4375bc24dbd6ad6264
|