原创

Redis基准测试

Redis 基准测试

简介

Redis 性能测试十分方便,官方自带了一个叫 redis-benchmark 的工具来模拟 N 个客户端同时发出 M 个请求。

使用方式

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

参数说明

英文都比较简单,直接阅读没啥问题。

redis-benchmark -h

命令 解释
-h Server hostname (default 127.0.0.1)
-p Server port (default 6379)
-s Server socket (overrides host and port)
-a Password for Redis Auth
-c Number of parallel connections (default 50)
-n Total number of requests (default 100000)
-d Data size of SET/GET value in bytes (default 3)
--dbnum SELECT the specified db number (default 0)
-k 1=keep alive 0=reconnect (default 1)
-r Use random keys for SET/GET/INCR, random values for SADD
-P Pipeline requests. Default 1 (no pipeline).
-e If server replies with errors, show them on stdout.
-q Quiet. Just show query/sec values
--csv Output in CSV format
-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.

命令测试

redis-benchmark -q
redis-benchmark -r 1000000 -n 2000000 -t get,set,lpush,lpop -P 16 -q

结果:

PING_INLINE: 86655.11 requests per second
PING_BULK: 89605.73 requests per second
SET: 84033.61 requests per second
GET: 98039.22 requests per second
INCR: 106382.98 requests per second
LPUSH: 91324.20 requests per second
RPUSH: 88573.96 requests per second
LPOP: 86281.27 requests per second
RPOP: 93720.71 requests per second
SADD: 93896.71 requests per second
HSET: 85251.49 requests per second
SPOP: 90991.81 requests per second
LPUSH (needed to benchmark LRANGE): 83682.01 requests per second
LRANGE_100 (first 100 elements): 42808.22 requests per second
LRANGE_300 (first 300 elements): 17067.76 requests per second
LRANGE_500 (first 450 elements): 12383.90 requests per second
LRANGE_600 (first 600 elements): 9304.92 requests per second
MSET (10 keys): 89605.73 requests per second

我们从上面的输出可以看出,redis 性能确实非常的帮,简单请求 qps 可达到 8w+,列表操作受到列表的大小限制,不过也挺快。

正文到此结束