大家好,今天我们来分享一下使用redis-benchmark对redis进行性能测试
进入redis 的默认安装目录:
[root@localhost ~]# cd /usr/local/bin/
指的就是这个压力测试工具,这是官方自带的
它的命令格式:
redis-benchmark [option] [option value]
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(L 的小写字母) 生成循环,永久执行测试
13 -t 仅运行以逗号分隔的测试命令列表。
14 -I(i 的大写字母) Idle 模式。仅打开 N 个 idle 连接并等待。
这就是它们参数的含义:
也许这样截图会比上面的清晰
启动Redis
[root@localhost bin]# redis-server redistest/redis.conf
12062:C 16 Mar 2022 17:26:25.446 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
12062:C 16 Mar 2022 17:26:25.446 # Redis version=5.0.8, bits=64, commit=00000000, modified=0, pid=12062, just started
12062:C 16 Mar 2022 17:26:25.446 # Configuration loaded
[root@localhost bin]#
连接Redis
[root@localhost bin]# redis-cli -p 6379
127.0.0.1:6379>
测试正常
在Redis运行的同时,复制一个别的终端
执行 redis-benchmark 测试
[root@localhost bin]# redis-benchmark -h 127.0.0.1 -p 6379 -c 100 -n 10000
这条命令的意思: 使用 redis-benchmark 来对本机(127.0.0.1 或 localhost)指定端口6379 100个并发连接,且每个并发连接10000个请求
它效于:
[root@localhost bin]# redis-benchmark -h localhost -p 6379 -c 100 -n 10000
[root@localhost bin]# cd /usr/local/bin/
[root@localhost bin]# redis-benchmark -h 127.0.0.1 -p 6379 -c 100 -n 10000
====== PING_INLINE ======
10000 requests completed in 0.13 seconds
100 parallel clients
3 bytes payload
keep alive: 1
91.02% <= 1 milliseconds
97.46% <= 2 milliseconds
99.89% <= 3 milliseconds
100.00% <= 3 milliseconds
78125.00 requests per second
====== PING_BULK ======
10000 requests completed in 0.12 seconds
100 parallel clients
3 bytes payload
keep alive: 1
94.39% <= 1 milliseconds
98.84% <= 2 milliseconds
99.98% <= 3 milliseconds
100.00% <= 3 milliseconds
81967.21 requests per second
====== SET ======
10000 requests completed in 0.12 seconds
100 parallel clients
3 bytes payload
keep alive: 1
93.37% <= 1 milliseconds
98.10% <= 2 milliseconds
99.92% <= 3 milliseconds
100.00% <= 3 milliseconds
82644.62 requests per second
====== GET ======
10000 requests completed in 0.12 seconds
100 parallel clients
3 bytes payload
keep alive: 1
95.25% <= 1 milliseconds
98.89% <= 2 milliseconds
100.00% <= 2 milliseconds
81967.21 requests per second
====== INCR ======
10000 requests completed in 0.12 seconds
100 parallel clients
3 bytes payload
keep alive: 1
95.46% <= 1 milliseconds
98.14% <= 2 milliseconds
99.84% <= 3 milliseconds
100.00% <= 3 milliseconds
81967.21 requests per second
====== LPUSH ======
10000 requests completed in 0.12 seconds
100 parallel clients
3 bytes payload
keep alive: 1
93.63% <= 1 milliseconds
98.94% <= 2 milliseconds
100.00% <= 2 milliseconds
82644.62 requests per second
====== RPUSH ======
10000 requests completed in 0.12 seconds
100 parallel clients
3 bytes payload
keep alive: 1
93.41% <= 1 milliseconds
98.06% <= 2 milliseconds
99.92% <= 3 milliseconds
100.00% <= 3 milliseconds
83333.34 requests per second
====== LPOP ======
10000 requests completed in 0.12 seconds
100 parallel clients
3 bytes payload
keep alive: 1
96.53% <= 1 milliseconds
99.21% <= 2 milliseconds
100.00% <= 2 milliseconds
82644.62 requests per second
====== RPOP ======
10000 requests completed in 0.12 seconds
100 parallel clients
3 bytes payload
keep alive: 1
96.63% <= 1 milliseconds
99.53% <= 2 milliseconds
100.00% <= 2 milliseconds
84745.77 requests per second
====== SADD ======
10000 requests completed in 0.12 seconds
100 parallel clients
3 bytes payload
keep alive: 1
97.04% <= 1 milliseconds
99.78% <= 2 milliseconds
100.00% <= 2 milliseconds
84745.77 requests per second
====== HSET ======
10000 requests completed in 0.13 seconds
100 parallel clients
3 bytes payload
keep alive: 1
89.62% <= 1 milliseconds
97.57% <= 2 milliseconds
99.39% <= 3 milliseconds
100.00% <= 3 milliseconds
76923.08 requests per second
====== SPOP ======
10000 requests completed in 0.12 seconds
100 parallel clients
3 bytes payload
keep alive: 1
95.91% <= 1 milliseconds
98.38% <= 2 milliseconds
99.75% <= 3 milliseconds
100.00% <= 3 milliseconds
80645.16 requests per second
====== LPUSH (needed to benchmark LRANGE) ======
10000 requests completed in 0.12 seconds
100 parallel clients
3 bytes payload
keep alive: 1
93.91% <= 1 milliseconds
99.48% <= 2 milliseconds
100.00% <= 2 milliseconds
83333.34 requests per second
====== LRANGE_100 (first 100 elements) ======
10000 requests completed in 0.18 seconds
100 parallel clients
3 bytes payload
keep alive: 1
76.23% <= 1 milliseconds
97.62% <= 2 milliseconds
99.30% <= 3 milliseconds
100.00% <= 3 milliseconds
55865.92 requests per second
====== LRANGE_300 (first 300 elements) ======
10000 requests completed in 0.39 seconds
100 parallel clients
3 bytes payload
keep alive: 1
0.41% <= 1 milliseconds
72.39% <= 2 milliseconds
96.66% <= 3 milliseconds
98.69% <= 4 milliseconds
98.92% <= 5 milliseconds
99.01% <= 41 milliseconds
99.05% <= 42 milliseconds
99.36% <= 43 milliseconds
99.58% <= 44 milliseconds
99.80% <= 45 milliseconds
100.00% <= 45 milliseconds
25445.29 requests per second
====== LRANGE_500 (first 450 elements) ======
10000 requests completed in 0.45 seconds
100 parallel clients
3 bytes payload
keep alive: 1
0.07% <= 1 milliseconds
17.88% <= 2 milliseconds
90.47% <= 3 milliseconds
98.37% <= 4 milliseconds
99.82% <= 5 milliseconds
100.00% <= 5 milliseconds
22222.22 requests per second
====== LRANGE_600 (first 600 elements) ======
10000 requests completed in 0.57 seconds
100 parallel clients
3 bytes payload
keep alive: 1
0.01% <= 1 milliseconds
1.49% <= 2 milliseconds
55.81% <= 3 milliseconds
95.05% <= 4 milliseconds
98.49% <= 5 milliseconds
98.98% <= 6 milliseconds
99.15% <= 7 milliseconds
99.32% <= 8 milliseconds
99.50% <= 9 milliseconds
99.63% <= 10 milliseconds
99.75% <= 11 milliseconds
99.88% <= 12 milliseconds
100.00% <= 13 milliseconds
17482.52 requests per second
====== MSET (10 keys) ======
10000 requests completed in 0.12 seconds
100 parallel clients
3 bytes payload
keep alive: 1
95.92% <= 1 milliseconds
99.67% <= 2 milliseconds
100.00% <= 2 milliseconds
85470.09 requests per second
查看这个信息
四个箭头,从上到下的意思
1.是10000个请求进行测试,10000个请求用时0.57秒
2. 模拟了100个客户端(100台计算机)
3. 每次写入3个字节
4. 一台服务器来测试请求(就是我们本机)
看下面:
这是处理的时间
每秒处理78125次请求
所以Redis相较于MySQL那样的关系型数据库来讲,很大的优势就在于Redis对高并发的处理能力
好了,有关于redis-benchmark对redis进行性能测试的实例,就到这里了,谢谢大家
|