redis banchmark(redis性能测试) 的使用

Redis 自带了一个叫 redis-benchmark 的工具来模拟 N 个客户端同时发出 M 个请求。 (类似于 Apache ab 程序)

参数说明:
-h Server hostname (default 127.0.0.1)
-p Server port (default 6379)
-s Server socket (overrides host and port)
-c Number of parallel connections (default 50) 并发客户端数
-n Total number of requests (default 10000) 请求数量
-d Data size of SET/GET value in bytes (default 2) set 数据大小
-k 1=keep alive 0=reconnect (default 1) 是否采用keep alive模式
-r Use random keys for SET/GET/INCR, random values for SADD 随机生成key的范围
Using this option the benchmark will get/set keys
in the form mykey_rand:000000012456 instead of constant
keys, the argument determines the max
number of values for the random number. For instance
if set to 10 only rand:000000000000 - rand:000000000009
range will be allowed.
-P Pipeline requests. Default 1 (no pipeline). 是否采用Pipeline模式请求,默认不采用
-q Quiet. Just show query/sec values 仅仅显示查询时间
--csv Output in CSV format 导出为CSV格式
-l Loop. Run the tests forever 循环测试
-t 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.

hash 相关操作的测试
./banchmark -r 500000 -n 500000 hmget myhash rand_int rand_int rand_int
redis-benchmark -r 500000 -n 500000 hget myhash rand_int rand_int

Leave a Reply

电子邮件地址不会被公开。 必填项已用*标注