redis linux测试,Redis性能测试

Redis自带redis-benchmark测试工具用来测试Redis的性能,redis-benchmark可以模拟多个客户端同时发送多个请求。

Usage: redis-benchmark [-h ] [-p ] [-c ] [-n [-k ]

-q 静默模式,只显示requests per second的值

-n 总共发起的请求数量

1.向6379这个redis实例发送500000个请求数redis-benchmark -p 6379 -q  -n 500000PING_INLINE: 66365.81 requests per second

PING_BULK: 61440.16 requests per second

SET: 55401.66 requests per second

GET: 66693.34 requests per second

INCR: 62790.41 requests per second

LPUSH: 57836.90 requests per second

LPOP: 68587.11 requests per second

SADD: 69280.87 requests per second

SPOP: 69803.16 requests per second

LPUSH (needed to benchmark LRANGE): 69473.39 requests per second

LRANGE_100 (first 100 elements): 35216.23 requests per second

LRANGE_300 (first 300 elements): 15170.36 requests per second

LRANGE_500 (first 450 elements): 10984.18 requests per second

LRANGE_600 (first 600 elements): 8499.21 requests per second

MSET (10 keys): 44980.21 requests per second

2.只测试几个命令redis-benchmark -p 26379 -q  -n 500000  -t set,get,mset

3.选择key space的大小

默认benchmark runs against单个key。

可以使用-r 参数为SET/GET/INCR操作使用随机KEY.redis-benchmark -t set -r 1000000 -n 1000000

4.使用pipeling

redis-benchmark默认模拟50个客户端,如果不指定-c参数。默认redis-benchmark在发送下一个命令之前需要接收到之前命令执行后的回复。

Redis支持PIPELING。一次可以发送多个命令。使用pipeling后明显测试的性能提高了#redis-benchmark -p 6379   -t set -r 1000000 -n 1000000  -q

SET: 59400.06 requests per second

# redis-benchmark -p 6379   -t set -r 1000000 -n 1000000  -q -P 10

SET: 276472.22 requests per second

# redis-benchmark -p 6379   -t set -r 1000000 -n 1000000  -q -P 20

SET: 304414.00 requests per second

# redis-benchmark -p 6379   -t set -r 1000000 -n 1000000  -q -P 30

SET: 320000.00 requests per second

# redis-benchmark -p 6379   -t set -r 1000000 -n 1000000  -q -P 50

SET: 337495.78 requests per second

# redis-benchmark -p 6379   -t set -r 1000000 -n 1000000  -q -P 100

SET: 359066.41 requests per second

# redis-benchmark -p 6379   -t set -r 1000000 -n 1000000  -q -P 200

SET: 307787.00 requests per second

# redis-benchmark -p 6379   -t set -r 1000000 -n 1000000  -q -P 300

SET: 293427.22 requests per second

# redis-benchmark -p 6379   -t set -r 1000000 -n 1000000  -q -P 400

SET: 276931.59 requests per second

5.影响Redis性能的主要因素

a.网络带宽和延迟对Redis的性能有直接的影响。

b.CPU。Redis是单线程设计,所以更快的CPU可以增加Redis的吞吐量。

c.内存

d.Redis在虚拟化环境下会比在物理机器上慢很多。

e.当Redis服务端和客户端在同一台机器上时,TCP端口和UNIX Sockets都可以使用。但是使用UNIX Sockets可以比使用TCP端口增加50%的吞吐量。

f.使用Redis pipeline的时候UNIX Sockets比TCP端口的性能优势有减小的趋势。

g.通过网卡访问Redis时,使用pipeline的数据在网卡数据包大小(大约1500字节)之下效率会更高。

.

6c4cd353f8bf0882748b3ef77b864d8b.png

h.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值