环境:
虚拟机: VMmare 16 pro
操作系统:CentOS Linux 7 ( cat /etc/os-release ) (4c 8G内存,64GB硬盘)
Redis版本: redis_version:4.0.2 ( 127.0.0.1:6379> info )
压测工具: redis-benchmark (redis 自带的压测工具 )
压测脚本1:
redis-benchmark -h 127.0.0.1 -p 6379 -c 100 -n 100000
脚本说明:-h 测试主机 -p 端口 -c 并发连接100 -n 10万个请求
会自行Redis自带的一些命令 ,测试执行效果
脚本执行结果说明:
====== SET ======
100000 requests completed in 0.49 seconds
100 parallel clients
3 bytes payload
keep alive: 1
99.90% <= 1 milliseconds
100.00% <= 1 milliseconds
204498.98 requests per second
====== GET ====== ---> 要执行的redis命令
100000 requests completed in 0.48 seconds ---> 10万请求 在0.48秒完成
100 parallel clients --->100个并发连接
3 bytes payload --->3 字节进行测试 payload
keep alive: 1
---> 以下是展示测试数据, 比显示每秒处理20.74万请求
99.93% <= 2 milliseconds
100.00% <= 2 milliseconds
207468.88 requests per second
压测脚本2 :
redis-benchmark -h 127.0.0.1 -p 6379 -q -d 100
存取大小为100字节的数据包 -q 简单输出
[root@localhost ~]# redis-benchmark -h 127.0.0.1 -p 6379 -q -d 100
PING_INLINE: 220750.55 requests per second
PING_BULK: 222222.23 requests per second
SET: 223713.64 requests per second
GET: 220264.31 requests per second
INCR: 219298.25 requests per second
LPUSH: 219298.25 requests per second
RPUSH: 215517.25 requests per second
LPOP: 215982.72 requests per second
RPOP: 220750.55 requests per second
SADD: 217391.30 requests per second
HSET: 219298.25 requests per second
SPOP: 218818.39 requests per second
LPUSH (needed to benchmark LRANGE): 219298.25 requests per second
LRANGE_100 (first 100 elements): 218340.61 requests per second
LRANGE_300 (first 300 elements): 217391.30 requests per second
LRANGE_500 (first 450 elements): 219780.22 requests per second
LRANGE_600 (first 600 elements): 220750.55 requests per second
MSET (10 keys): 235294.11 requests per second
[root@localhost ~]#
压测脚本3 :
redis-benchmark -t set,lpush -q -n 100000
只测试某些操作的 性能
[root@localhost ~]# redis-benchmark -t set,lpush -q -n 100000
SET: 222222.23 requests per second
LPUSH: 220750.55 requests per second
[root@localhost ~]#
压测脚本4 :
redis-benchmark -n 100000 -q script load "redis.call('set','foo','bar' )"
只测试某些数值存取的性能, 调用set语句
[root@localhost ~]# redis-benchmark -n 100000 -q script load "redis.call('set','foo','bar' )"
script load redis.call('set','foo','bar' ): 218818.39 requests per second
[root@localhost ~]#