Redis 性能测试
程序员文章站
2022-07-04 09:15:14
...
Redis 性能测试是通过同时执行多个命令实现的。
Redis 性能测试的基本命令如下:
redis-benchmark [option] [option value]
以下实例同时执行 1000 个请求来检测性能:
redis-benchmark -h 172.19.24.222 -p 6381 -c 100 -n 1000 ====== PING_INLINE ====== 1000 requests completed in 0.04 seconds 100 parallel clients 3 bytes payload keep alive: 1 0.10% <= 1 milliseconds 48.30% <= 2 milliseconds 98.80% <= 3 milliseconds 100.00% <= 3 milliseconds 26315.79 requests per second ====== PING_BULK ====== 1000 requests completed in 0.04 seconds 100 parallel clients 3 bytes payload keep alive: 1 0.10% <= 1 milliseconds 59.40% <= 2 milliseconds 99.50% <= 3 milliseconds 100.00% <= 3 milliseconds 27027.03 requests per second ====== SET ====== 1000 requests completed in 0.04 seconds 100 parallel clients 3 bytes payload keep alive: 1 0.10% <= 1 milliseconds 54.70% <= 2 milliseconds 93.80% <= 3 milliseconds 99.80% <= 4 milliseconds 100.00% <= 4 milliseconds 27777.78 requests per second ====== GET ====== 1000 requests completed in 0.03 seconds 100 parallel clients 3 bytes payload keep alive: 1 0.10% <= 1 milliseconds 76.40% <= 2 milliseconds 100.00% <= 2 milliseconds 33333.34 requests per second ....省略 ====== MSET (10 keys) ====== 1000 requests completed in 0.04 seconds 100 parallel clients 3 bytes payload keep alive: 1 0.10% <= 1 milliseconds 27.70% <= 2 milliseconds 96.80% <= 3 milliseconds 100.00% <= 3 milliseconds 25000.00 requests per second
Redis 性能测试工具可选参数如下:
序号 | 选项 | 描述 | 默认值 |
1 | -h | 指定服务器主机名 | 127.0.0.1 |
2 | -p | 指定服务器端口 | 6379 |
3 | -s | 指定服务器 socket | |
4 | -c | 指定并发连接数 | 50 |
5 | -n | 指定请求数 | 10000 |
6 | -d | 以字节的形式指定 SET/GET 值的数据大小 | 2 |
7 | -k | 1=keep alive 0=reconnect | 1 |
8 | -r | SET/GET/INCR 使用随机 key, SADD 使用随机值 | |
9 | -P | 通过管道传输 <numreq> 请求 | 1 |
10 | -q | 强制退出 redis。仅显示 query/sec 值 | |
11 | --csv | 以 CSV 格式输出 | |
12 | -l | 生成循环,永久执行测试 | |
13 | -t | 仅运行以逗号分隔的测试命令列表。 | |
14 | -I | Idle 模式。仅打开 N 个 idle 连接并等待。 |
上一篇: spring boot 配置默认欢迎页
下一篇: 常用的表单参数排序验签