Redis Benchmark性能测试
性能测试的作用是让我们了解 Redis 服务器的性能优劣。在实际的业务场景中,性能测试是必不可少的。在业务系统上线之前,我们都需要清楚地了解 Redis 服务器的性能,从而避免发生某些意外情况,比如数据量过大会导致服务器宕机等。
测试令格式
执行测试令,要在 Redis 的安装目录下执行,令如下所示:
其中 option 为可选参数, option value 为具体的参数值。 redis-benchmark 令的可选参数如下所示:redis-benchmark [option] [option value]
参数选项 | 说明 |
|---|---|
-h | 指定服务器主机名。 |
-p | 指定服务器端口。 |
-s | 指定服务器 socket。 |
-c | 指定并发连接数。 |
-n | 指定请求的具体数量。 |
-d | 以字节的形式指定 SET/GET 值的数据大小。 |
-k | 1 表示 keep alive;0 表示 reconnect,默认为 1。 |
-r | SET/GET/INCR 使用随机 key, SADD 使用随机值。 |
-P | Pipeline 请求 |
-q | 强制退出 Redis,仅显示 query/sec 值。 |
--csv | 以 CSV 格式输出。 |
-l | 生成循环,执行测试。 |
-t | 仅运行以逗号分隔的测试令列表。 |
-I(大写i) | 空闲模式,打开 N 个空闲连接并等待连接。 |
在 Windows 系统下,其目录文件如图所示:

图1:Redis Benchmark性能测试
执行测试令
1) Windows环境
在 Windows 10 系统环境下,同时执行了 10000 个令来检测 Redis 服务器的性能,示例如下:D:\Redis-x64-5.0.10>redis-benchmark.exe -n 10000 -q
PING_INLINE: 21786.49 requests per second
PING_BULK: 21231.42 requests per second
#每秒执行22935.78个请求
SET: 22935.78 requests per second
GET: 22573.36 requests per second
INCR: 19011.41 requests per second
LPUSH: 7473.84 requests per second
RPUSH: 20618.56 requests per second
LPOP: 17793.60 requests per second
RPOP: 21367.52 requests per second
SADD: 15847.86 requests per second
HSET: 21551.72 requests per second
SPOP: 19531.25 requests per second
LPUSH (needed to benchmark LRANGE): 18348.62 requests per second
LRANGE_100 (first 100 elements): 6835.27 requests per second
LRANGE_300 (first 300 elements): 4535.15 requests per second
LRANGE_500 (first 450 elements): 3913.89 requests per second
LRANGE_600 (first 600 elements): 3177.63 requests per second
MSET (10 keys): 15128.59 requests per second
注意:若是 Linux 系统,其每秒钟执行的请求数量是 Windows 系统的好几倍。
2) Linux环境
Linux 环境下,Redis 的性能测试结果,如下所示:
$ redis-benchmark -n 10000 -q
PING_INLINE: 141043.72 requests per second
PING_BULK: 142857.14 requests per second
#服务器每秒执行的请求数量
SET: 141442.72 requests per second
GET: 145348.83 requests per second
INCR: 137362.64 requests per second
LPUSH: 145348.83 requests per second
LPOP: 146198.83 requests per second
SADD: 146198.83 requests per second
SPOP: 149253.73 requests per second
LPUSH (needed to benchmark LRANGE): 148588.42 requests per second
LRANGE_100 (first 100 elements): 58411.21 requests per second
LRANGE_300 (first 300 elements): 21195.42 requests per second
LRANGE_500 (first 450 elements): 14539.11 requests per second
LRANGE_600 (first 600 elements): 10504.20 requests per second
MSET (10 keys): 93283.58 requests per second
3) 执行指定的测试令
带参数的令,使用示例如下:
D:\Redis-x64-5.0.10>redis-benchmark.exe -h 127.0.0.1 -p 6379 -n 10000 -t set,get,lpush -q
SET: 17064.85 requests per second
GET: 16051.36 requests per second
LPUSH: 14224.75 requests per second
- 随机文章
- 核心危机(核心危机魔石合成攻略)
- 风儿(风儿轻轻的吹)
- 饿了么红包怎么用(饿了么红包怎么用微信支付)
- 儿童教育文章(儿童教育)
- 光遇花手先祖位置(安卓光遇手花先祖)
- 广州4a广告公司(广州4a广告公司创意总监年薪)
- 抖音卡(抖音卡顿怎么解决)
- xboxones(xboxone手柄怎么配对主机)
- 兵马俑(兵马俑介绍和历史背景)
- 陈武简历
- 帆船比赛(帆船比赛视频)
- 儋州市第二中学(儋州市第二中学录取分数线)
- 鬼泣5攻略(鬼泣5攻略第三关怎么跳)
- 地球日主题(2020年世界地球日主题)
- 和柳亚子(和柳亚子先生于田)
- 冰客(冰客果汁)
- yy魔兽(yy魔兽世界)
- 国外成人游戏(国外成人游戏注册需要visa信用卡)
- 充值卡代理(充值卡代理加盟)
- 拆奶罩
- 郭妮小说(恶魔的法则郭妮小说)
- 东天目山(东天目山景区)
- 杭同(杭同培训中心怎么样)
- 蝙蝠给人类的一封信(蝙蝠给人类的一封信)
- 大松电饭煲(美的大松电饭煲)
- 服饰加盟(服饰加盟店招商)
- 疯狂填字(疯狂填字5)
- 点对点短信息(点对点短信息费是什么意思)
- 观音普门品(观音普门品念诵全文)
- 河北省大运会(河北省大运会时间)
