Redis 自带了一个叫 redis-benchmark 的工具来模拟 N 个客户端同时发出 M 个请求。 (类似于 Apache ab 程序)。你可以使用 redis-benchmark -h 来查看基准参数。
image.pngUsage: redis-benchmark [-h <host>] [-p <port>] [-c <clients>] [-n <requests]> [-k <boolean>]
-h <hostname> Server hostname (default 127.0.0.1) 服务地址
-p <port> Server port (default 6379) 服务端口
-s <socket> Server socket (overrides host and port)
-a <password> Password for Redis Auth
-c <clients> Number of parallel connections (default 50) 并行客户端数量 默认50
-n <requests> Total number of requests (default 100000) 测试请求次数 默认100000
-d <size> Data size of SET/GET value in bytes (default 2) 数据包大小 默认2bytes
-dbnum <db> SELECT the specified db number (default 0)
-k <boolean> 1=keep alive 0=reconnect (default 1) 链接存活时间
-r <keyspacelen> Use random keys for SET/GET/INCR, random values for SADD
Using this option the benchmark will expand the string rand_int
inside an argument with a 12 digits number in the specified range
from 0 to keyspacelen-1. The substitution changes every time a command
is executed. Default tests use this to hit random keys in the
specified range.
-P <numreq> Pipeline <numreq> requests. Default 1 (no pipeline).
-q Quiet. Just show query/sec values
--csv Output in CSV format
-l Loop. Run the tests forever
-t <tests> 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 -n 100000 -t GET,SET
====== SET ======
100000 requests completed in 1.60 seconds
50 parallel clients
3 bytes payload
keep alive: 1
multi-thread: no
0.00% <= 0.2 milliseconds
4.91% <= 0.3 milliseconds
46.50% <= 0.4 milliseconds
74.06% <= 0.5 milliseconds
85.52% <= 0.6 milliseconds
90.30% <= 0.7 milliseconds
92.95% <= 0.8 milliseconds
94.85% <= 0.9 milliseconds
96.10% <= 1.0 milliseconds
96.97% <= 1.1 milliseconds
97.56% <= 1.2 milliseconds
97.99% <= 1.3 milliseconds
98.31% <= 1.4 milliseconds
98.55% <= 1.5 milliseconds
98.72% <= 1.6 milliseconds
98.85% <= 1.7 milliseconds
98.96% <= 1.8 milliseconds
99.04% <= 1.9 milliseconds
99.11% <= 2 milliseconds
99.66% <= 3 milliseconds
99.87% <= 4 milliseconds
99.92% <= 5 milliseconds
99.93% <= 6 milliseconds
99.97% <= 7 milliseconds
100.00% <= 8 milliseconds
100.00% <= 8 milliseconds
62421.97 requests per second
====== GET ======
100000 requests completed in 1.70 seconds
50 parallel clients
3 bytes payload
keep alive: 1
multi-thread: no
94.45% <= 1 milliseconds
98.95% <= 2 milliseconds
99.45% <= 3 milliseconds
99.75% <= 4 milliseconds
99.82% <= 5 milliseconds
99.83% <= 6 milliseconds
99.84% <= 7 milliseconds
99.87% <= 8 milliseconds
99.96% <= 9 milliseconds
99.98% <= 10 milliseconds
99.99% <= 11 milliseconds
99.99% <= 15 milliseconds
99.99% <= 16 milliseconds
100.00% <= 17 milliseconds
100.00% <= 18 milliseconds
58719.91 requests per second
网友评论