项目作者: fetlife

项目描述 :
Redis Memory Analyzer written in Rust
高级语言: Rust
项目地址: git://github.com/fetlife/redis-analyzer.git
创建时间: 2019-07-12T00:08:27Z
项目社区:https://github.com/fetlife/redis-analyzer

开源协议:

下载


Redis Analyzer

Console tool to scan keys in Redis database in real time and aggregate count and memory usage statistics by key prefixes.

Features:

  • Keys count and memory usage statistics
  • Concurrent scanning of multiple Redis databases
  • Low memory signature
  • Fast (scans instances with dozens of millions of keys in few minutes)

Motivation

There are already good tools out there doing similar job with even more features:

But using them on big Redis databases with millions of keys is not viable because of memory requirements and time it takes to complete the full scan.

Installation

You’ll need rust and cargo. See here for instructions on how to get them.

Then you can just run cargo install redis-analyzer to install it.

Alternatively, to build it yourself, clone the repository and run cargo build --release.

Usage

  1. # redis-analyzer --help
  2. redis-analyzer 0.2.0
  3. Analyzes keys in Redis to produce breakdown of the most frequent prefixes.
  4. USAGE:
  5. redis-analyzer [FLAGS] [OPTIONS] --urls <URL1,URL2>
  6. FLAGS:
  7. --full-keys Shows full keys in result instead of just suffixes.
  8. -h, --help Prints help information
  9. --progress Shows progress
  10. -V, --version Prints version information
  11. OPTIONS:
  12. -c, --concurrency <CONCURRENCY>
  13. Maximum number of hosts scanned at the same time. [default: number of logical CPUs]
  14. -d, --depth <DEPTH> Maximum key depth to examine.
  15. -f, --format <plain|json> Output format. (default: plain)
  16. --min-count-percentage <MIN_PREFIX_COUNT_PERCENTAGE>
  17. Minimum prefix frequency in percentages for prefix to be included in the result. [default: 1.0]
  18. --order <count|memory> Sort order. [default: memory]
  19. --scan-size <SCAN_SIZE>
  20. Configures how many keys are fetched at a time. [default: 100]
  21. -s, --separators <SEPARATORS> List of key separators. [default: :/|]
  22. -u, --urls <URL1,URL2> List of URLs to scan.

Examples

Example output:

  1. $ redis-analyzer -u 127.0.0.1:6379/0,127.0.0.1:6379/2
  2. Took 976ms 142us
  3. Keys Count Memory Usage
  4. ALL -------------------15155 (100.00%) --------------26.88MB (100.00%)
  5. ├─ cache --------------├─ 294 (1.94%) ---------------├─ 2.04MB (7.60%)
  6. └─ Touchify --------│--└─ 239 (81.29%) -----------│--└─ 20.62KB (0.99%)
  7. └─ internal -----│-----└─ 239 (100.00%) -------│-----└─ 20.62KB (100.00%)
  8. └─ User ------│--------└─ 239 (100.00%) ----│--------└─ 20.62KB (100.00%)
  9. ├─ feed ---------------├─ 158 (1.04%) ---------------├─ 1.60MB (5.97%)
  10. └─ feed ------------│--└─ 158 (100.00%) ----------│--└─ 1.60MB (100.00%)
  11. └─ feeds --------│-----└─ 155 (98.10%) --------│-----└─ 1.60MB (99.93%)
  12. ├─ hovno --------------├─ 13808 (91.11%) ------------├─ 1.55MB (5.75%)
  13. ├─ sidekiq ------------├─ 399 (2.63%) ---------------├─ 1.27MB (4.74%)
  14. └─ stat ------------│--└─ 388 (97.24%) -----------│--└─ 28.21KB (2.16%)
  15. ├─ processed ----│-----├─ 194 (50.00%) --------│-----├─ 14.58KB (51.68%)
  16. └─ failed -------│-----└─ 194 (50.00%) --------│-----└─ 13.63KB (48.32%)
  17. ├─ stat ---------------├─ 176 (1.16%) ---------------├─ 11.24KB (0.04%)
  18. ├─ counts -------------├─ 120 (0.79%) ---------------├─ 9.68KB (0.04%)
  19. └─ [other] ------------└─ 200 (1.32%) ---------------└─ 20.39MB (75.86%)
  1. $ redis-analyzer -u 127.0.0.1:6379/0 -d 1
  2. Took 752ms 708us
  3. Keys Count Memory Usage
  4. ALL -----------14971 (100.00%) ------7.29MB (100.00%)
  5. ├─ cache ------├─ 294 (1.96%) -------├─ 2.04MB (28.02%)
  6. ├─ feed -------├─ 158 (1.06%) -------├─ 1.60MB (22.00%)
  7. ├─ hovno ------├─ 13808 (92.23%) ----├─ 1.55MB (21.19%)
  8. ├─ sidekiq ----├─ 399 (2.67%) -------├─ 1.27MB (17.42%)
  9. ├─ counts -----├─ 120 (0.80%) -------├─ 9.68KB (0.13%)
  10. └─ [other] ----└─ 192 (1.28%) -------└─ 840.05KB (11.25%)
  1. $ redis-analyzer -u 127.0.0.1:6379/0 -d 2 --order count --full-keys
  2. Took 838ms 811us
  3. Keys Count Memory Usage
  4. ALL ---------------------14971 (100.00%) --------7.29MB (100.00%)
  5. ├─ hovno ----------------├─ 13808 (92.23%) ------├─ 1.55MB (21.19%)
  6. ├─ sidekiq --------------├─ 399 (2.67%) ---------├─ 1.27MB (17.42%)
  7. └─ sidekiq:stat ------│--└─ 388 (97.24%) -----│--└─ 28.21KB (2.17%)
  8. ├─ cache ----------------├─ 294 (1.96%) ---------├─ 2.04MB (28.02%)
  9. └─ cache:Touchify ----│--└─ 239 (81.29%) -----│--└─ 20.62KB (0.99%)
  10. ├─ feed -----------------├─ 158 (1.06%) ---------├─ 1.60MB (22.00%)
  11. └─ feed:feed ---------│--└─ 158 (100.00%) ----│--└─ 1.60MB (100.00%)
  12. ├─ counts ---------------├─ 120 (0.80%) ---------├─ 9.68KB (0.13%)
  13. └─ [other] --------------└─ 192 (1.28%) ---------└─ 840.05KB (11.25%)