redis-benchmark并发压力测试的问题解析
前言:
Redis-benchmark:
Redis 自带了一个叫 redis-benchmark 的工具来模拟 N 个客户端同时发出 M 个请求。 (类似于 Apache ab 程序)。你可以使用 redis-benchmark -h 来查看基准参数。
参数简介:
支持以下参数:
用法:redis-benchmark [-h <主机>] [-p <端口>] [-c <客户端>] [-n <请求]> [-k <布尔>]
-h <主机名>服务器主机名(默认值为127.0.0.1)
-p <端口>服务器端口(默认6379) # 作者喜欢的一个女明星名字9键就是6397 !!!∑("htmlcode">
redis-benchmark -h localhost -p 6379 -a adc.123 -c 100 -n 100000 -q redis-benchmark 后面跟参数 这里我测试了 -c100并发和-n 100000请求 -q 静默,不显示细节
以下是测试结果
[root@localhost bin]# redis-benchmark -h localhost -p 6379 -a adc.123 -c 100 -n 100000 -q
PING_INLINE: 126582.27 requests per second
PING_BULK: 123915.74 requests per second
2939:M 07 Jan 2021 20:01:14.327 * 10000 changes in 60 seconds. Saving...
2939:M 07 Jan 2021 20:01:14.328 * Background saving started by pid 75528
75528:C 07 Jan 2021 20:01:14.330 * DB saved on disk
75528:C 07 Jan 2021 20:01:14.331 * RDB: 5 MB of memory used by copy-on-write
2939:M 07 Jan 2021 20:01:14.428 * Background saving terminated with success
SET: 125786.16 requests per second
GET: 123762.38 requests per second
INCR: 125156.45 requests per second
LPUSH: 127551.02 requests per second
RPUSH: 126903.55 requests per second
LPOP: 127388.53 requests per second
RPOP: 125470.52 requests per second
SADD: 125786.16 requests per second
HSET: 125470.52 requests per second
SPOP: 122549.02 requests per second
ZADD: 125786.16 requests per second
ZPOPMIN: 123915.74 requests per second
LPUSH (needed to benchmark LRANGE): 127551.02 requests per second
LRANGE_100 (first 100 elements): 57703.40 requests per second
LRANGE_300 (first 300 elements): 24319.07 requests per second
LRANGE_500 (first 450 elements): 17500.88 requests per second
LRANGE_600 (first 600 elements): 13958.68 requests per second
MSET (10 keys): 123001.23 requests per seco
可以看到 set 写入 每秒约 12w,读取每秒约12w,综合每秒约12w。
下面我们把 -q去掉,看下详细信息,应为太多,只调取了写入和读取的信息。
redis-benchmark -h localhost -p 6379 -a adc.123 -c 100 -n 100000 2939:M 07 Jan 2021 20:08:49.475 * Background saving terminated with success ====== SET ====== 100000 requests completed in 0.80 seconds #100000个数据请求0.8秒内完成 100 parallel clients #100并发量 3 bytes payload #写入3字节 可以 -d 指定 keep alive: 1 #只有一台服务器来处理这些请求,单机性能 multi-thread: no 97.47% <= 1 milliseconds 99.88% <= 2 milliseconds 99.97% <= 3 milliseconds 100.00% <= 3 milliseconds #总共用了 3毫秒 完成写入 124843.95 requests per second #每秒写入约 12w数据 ====== GET ====== 100000 requests completed in 0.80 seconds 100 parallel clients 3 bytes payload keep alive: 1 multi-thread: no 97.43% <= 1 milliseconds 99.70% <= 2 milliseconds 100.00% <= 2 milliseconds 125313.29 requests per second
下一篇:Redis实战之商城购物车功能的实现代码