LEN

测算Redis处理实际生产请求的QPS/TPS
公司用到redis 的地方非常多 我测试下自己的QPS使用 redis发布版本中自带了redis-benchma...
扫描右侧二维码阅读全文
02
2017/07

测算Redis处理实际生产请求的QPS/TPS

公司用到redis 的地方非常多 我测试下自己的QPS
使用 redis发布版本中自带了redis-benchmark性能测试工具;
使用50个并发连接,发出100000个请求,每个请求的数据为2kb,
测试host为127.0.0.1 端口为6379的redis服务器性能:
命令:

redis-benchmark -h 127.0.0.1 -p 6379 -c 50 -n 100000 -d 2

输出 :

====== PING_INLINE ======
  100000 requests completed in 1.47 seconds
  50 parallel clients
  2 bytes payload
  keep alive: 1

99.62% <= 1 milliseconds
99.95% <= 41 milliseconds
100.00% <= 41 milliseconds
67888.66 requests per second

====== PING_BULK ======
  100000 requests completed in 1.49 seconds
  50 parallel clients
  2 bytes payload
  keep alive: 1

99.57% <= 1 milliseconds
100.00% <= 1 milliseconds
66934.41 requests per second

====== SET ======
  100000 requests completed in 1.70 seconds
  50 parallel clients
  2 bytes payload
  keep alive: 1

98.37% <= 1 milliseconds
99.83% <= 2 milliseconds
99.85% <= 4 milliseconds
99.90% <= 15 milliseconds
99.95% <= 215 milliseconds
99.97% <= 216 milliseconds
100.00% <= 216 milliseconds
58858.15 requests per second

====== GET ======
  100000 requests completed in 1.45 seconds
  50 parallel clients
  2 bytes payload
  keep alive: 1

99.55% <= 1 milliseconds
100.00% <= 2 milliseconds
100.00% <= 2 milliseconds
69013.11 requests per second

====== INCR ======
  100000 requests completed in 1.31 seconds
  50 parallel clients
  2 bytes payload
  keep alive: 1

99.52% <= 1 milliseconds
100.00% <= 2 milliseconds
76219.51 requests per second

====== LPUSH ======
  100000 requests completed in 1.42 seconds
  50 parallel clients
  2 bytes payload
  keep alive: 1

98.82% <= 1 milliseconds
99.95% <= 2 milliseconds
100.00% <= 2 milliseconds
70422.54 requests per second

====== LPOP ======
  100000 requests completed in 1.39 seconds
  50 parallel clients
  2 bytes payload
  keep alive: 1

98.55% <= 1 milliseconds
100.00% <= 2 milliseconds
100.00% <= 2 milliseconds
72150.07 requests per second

====== SADD ======
  100000 requests completed in 1.43 seconds
  50 parallel clients
  2 bytes payload
  keep alive: 1

99.47% <= 1 milliseconds
100.00% <= 1 milliseconds
70028.02 requests per second

====== SPOP ======
  100000 requests completed in 1.47 seconds
  50 parallel clients
  2 bytes payload
  keep alive: 1

99.45% <= 1 milliseconds
100.00% <= 2 milliseconds
67934.78 requests per second

====== LPUSH (needed to benchmark LRANGE) ======
  100000 requests completed in 1.43 seconds
  50 parallel clients
  2 bytes payload
  keep alive: 1

98.53% <= 1 milliseconds
100.00% <= 2 milliseconds
100.00% <= 2 milliseconds
69832.40 requests per second

====== LRANGE_100 (first 100 elements) ======
  100000 requests completed in 4.10 seconds
  50 parallel clients
  2 bytes payload
  keep alive: 1

32.39% <= 1 milliseconds
99.56% <= 2 milliseconds
100.00% <= 2 milliseconds
24378.35 requests per second

====== LRANGE_300 (first 300 elements) ======
  100000 requests completed in 9.28 seconds
  50 parallel clients
  2 bytes payload
  keep alive: 1

0.00% <= 1 milliseconds
0.01% <= 2 milliseconds
99.33% <= 3 milliseconds
99.98% <= 4 milliseconds
100.00% <= 4 milliseconds
10770.06 requests per second

====== LRANGE_500 (first 450 elements) ======
  100000 requests completed in 12.75 seconds
  50 parallel clients
  2 bytes payload
  keep alive: 1

0.00% <= 2 milliseconds
7.22% <= 3 milliseconds
98.10% <= 4 milliseconds
99.14% <= 5 milliseconds
99.54% <= 6 milliseconds
99.75% <= 7 milliseconds
99.89% <= 8 milliseconds
99.98% <= 9 milliseconds
99.98% <= 10 milliseconds
100.00% <= 11 milliseconds
100.00% <= 11 milliseconds
7841.91 requests per second

====== LRANGE_600 (first 600 elements) ======
  100000 requests completed in 16.08 seconds
  50 parallel clients
  2 bytes payload
  keep alive: 1

0.00% <= 2 milliseconds
0.05% <= 3 milliseconds
57.90% <= 4 milliseconds
99.17% <= 5 milliseconds
99.93% <= 6 milliseconds
100.00% <= 7 milliseconds
100.00% <= 7 milliseconds
6217.36 requests per second

====== MSET (10 keys) ======
  100000 requests completed in 2.92 seconds
  50 parallel clients
  2 bytes payload
  keep alive: 1

0.39% <= 1 milliseconds
97.30% <= 2 milliseconds
99.15% <= 3 milliseconds
99.50% <= 4 milliseconds
99.85% <= 5 milliseconds
99.90% <= 6 milliseconds
99.95% <= 30 milliseconds
100.00% <= 31 milliseconds
100.00% <= 31 milliseconds
34258.31 requests per second

仅看 每个操作的 requests per second 参数

测算redis处理实际生产请求的QPS/TPS在实际生产中,我们需要关心这个指标,在我们的应用场景中,
redis能够处理的最大的(QPS/TPS)是多少?
测量redis QPS的方式有两种:

估计生产的报文大小,使用benchmark工具指定-d数据块大小来模拟;
使用redis-cli中info统计信息计算差值;
redis-cli的info命令中有一项total_commands_processed表示:从启动到现在处理的所有命令总数,可以通过统计两次info指令间的差值来计算QPS:

生产环境统计

redis-cli -h 127.0.0.1 -p 6379 info |grep -i total_commands_processed | awk -F ':' '{print "'$(date +%H:%M:%S)' " $2}'

使用watch -n1 每秒查看一次 这样状态就回每秒更新

watch -n1 redis-cli -h 127.0.0.1 -p 6379 info stats

Every 1.0s: redis-cli -h 127.0.0.1 -p 6379 info stats                                                                                                         Sat Jul  1 15:48:18 2017
# Stats
total_connections_received:6053962
total_commands_processed:596138332
instantaneous_ops_per_sec:292
total_net_input_bytes:47770646646
total_net_output_bytes:35112660886004
instantaneous_input_kbps:18.51
instantaneous_output_kbps:27963.46
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
evicted_keys:0
keyspace_hits:861725
keyspace_misses:1158168
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:0
migrate_cached_sockets:0
最后修改:2017 年 07 月 02 日 11 : 17 PM
如果觉得我的文章对你有用,请随意赞赏

发表评论