Redis-benchmark concurrent stress test

Foreword:

Redis-benchmark:
Redis comes with a tool called redis-benchmark to simulate N clients making M requests at the same time. (Similar to the Apache ab program). You can use redis-benchmark -h to view the benchmark parameters.

Introduction to parameters:

支持以下参数:
用法:redis-benchmark [-h <主机>] [-p <端口>] [-c <客户端>] [-n <请求]> [-k <布尔>]
-h      <主机名>服务器主机名(默认值为127.0.0.1)
-p      <端口>服务器端口(默认6379) # 作者喜欢的一个女明星名字9键就是6397  !!!∑(゚Д゚ノ)ノ
-s      <socket>服务器套接字(覆盖主机和端口)
-a      <密码> Redis身份验证的密码
-c      <客户端>并行连接数(默认为50)
-n      <请求>请求总数(默认为100000)
-d      <大小> SET / GET值的数据大小(以字节为单位)(默认为2)
-dbnum  <db>选择指定的数据库号(默认为0)
-k      <布尔值> 1 =保持活动状态0 =重新连接(默认1)
-r      <keyspacelen>将随机键用于SET / GET / INCR,将随机值用于SADD 使用此选项,基准测试将扩展字符串__ rand_ int__在具有指定范围内的12位数字的参数中从0到keyspacelen-1。 每次命令替换都会更改
被执行。 默认测试使用它来击中指定范围。
-P     <numreq>管道<numreq>请求。 默认值1(无管道)。
-q     只显示查询/秒值
--csv  以CSV格式输出
-l     循环测试

-t     <测试>仅运行逗号分隔的测试列表。 测试名称与输出名称相同。

-I      空闲模式。 只需打开N个空闲连接并等待。 

start testing:

redis-benchmark -h localhost -p 6379 -a adc.123 -c 100 -n 100000 -q
redis-benchmark 后面跟参数 这里我测试了 -c100并发和-n 100000请求 -q 静默,不显示细节

The following are the test results

[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

It can be seen that the set write is about 12w per second, the read is about 12w per second, and the combined is about 12w per second.

Next, we remove -q and look at the detailed information. It should be too much, and only the information written and read is called.

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

Guess you like

Origin blog.csdn.net/qq_26129413/article/details/112326018