Redis官方已经说了,Redis有官方自己的性能测试工具!https://redis.io/topics/benchmarks

我们自己试试吧

redis-benchmark [-h <host>] [-p <port>] [-c <clients>] [-n <requests]> [-k <boolean>]


## 参数说明
 -h <hostname>      Server hostname (default 127.0.0.1) 服务地址,默认是127.0.0.1
 -p <port>          Server port (default 6379) 服务端口,默认是6379
 -s <socket>        Server socket (overrides host and port)
 -a <password>      Password for Redis Auth 认证Redis的密码
 -c <clients>       Number of parallel connections (default 50)
 -n <requests>      Total number of requests (default 100000) 测试的总请求数,默认是10万
 -d <size>          Data size of SET/GET value in bytes (default 2)
 --dbnum <db>       SELECT the specified db number (default 0) 选择指定的db编号(默认为0)
 -k <boolean>       1=keep alive 0=reconnect (default 1)
 -r <keyspacelen>   Use random keys for SET/GET/INCR, random values for SADD
  Using this option the benchmark will expand the string __rand_int__
  inside an argument with a 12 digits number in the specified range
  from 0 to keyspacelen-1. The substitution changes every time a command
  is executed. Default tests use this to hit random keys in the
  specified range.
 -P <numreq>        Pipeline <numreq> requests. Default 1 (no pipeline). 管道请求。默认值1(无管道)。
 -q                 Quiet. Just show query/sec values 仅显示查询/秒值
 --csv              Output in CSV format 以CSV格式输出
 -l                 Loop. Run the tests forever 一直循环测试
 -t <tests>         Only run the comma separated list of tests. The test
                    names are the same as the ones produced as output.
 -I                 Idle mode. Just open N idle connections and wait.

官方的一个所有种类测试的典型例子

# 测试阶段 服务器CPU性能会占用变高
redis-benchmark -q -n 100000

测试结果如下:

图片说了 每秒SET 命令能处理34545.32个请求。其他的自行查看

云服务器CPU更强,性能更好,CPU到95% 跑个5W qps 没问题!

宝塔Redis 的性能测试在:/www/server/redis/src/

# 进入宝塔 redis-benchmark
cd /www/server/redis/src 

# 进行测试
./redis-benchmark -q -n 100000 -a 密码 -p 端口

示例:
./redis-benchmark -q -n 100000 -a 密码 -p 6379
特殊说明:
上述文章均是作者实际操作后产出。烦请各位,请勿直接盗用!转载记得标注原文链接:www.zanglikun.com
第三方平台不会及时更新本文最新内容。如果发现本文资料不全,可访问本人的Java博客搜索:标题关键字。以获取全部资料 ❤