51Testing软件测试论坛

标题: 每日一例:Redis性能测试 [打印本页]

作者: lsekfe    时间: 2022-5-18 11:13
标题: 每日一例:Redis性能测试
Part1前言
  都说   Redis    性能极致,实际到底怎么样呢?我们借助   redis-benchmark    来测试一下。  redis-benchmark    是   Redis   自带的测试工具,简直不要太舒服。
  Part2性能测试
  1、快速测试
  测试命令:  redis-benchmark  
  1. [root@RLKJ-BT ~]# redis-benchmark
  2.   ====== PING_INLINE ======
  3.     100000 requests completed in 1.66 seconds
  4.     50 parallel clients
  5.     3 bytes payload
  6.     keep alive: 1
  7.   98.94% <= 1 milliseconds
  8.   99.55% <= 2 milliseconds
  9.   99.60% <= 5 milliseconds
  10.   99.61% <= 6 milliseconds
  11.   99.65% <= 10 milliseconds
  12.   99.87% <= 11 milliseconds
  13.   99.99% <= 12 milliseconds
  14.   100.00% <= 12 milliseconds
  15.   60240.96 requests per second
  16.   ====== PING_BULK ======
  17.     100000 requests completed in 1.53 seconds
  18.     50 parallel clients
  19.     3 bytes payload
  20.     keep alive: 1
  21.   99.25% <= 1 milliseconds
  22.   99.94% <= 2 milliseconds
  23.   100.00% <= 2 milliseconds
  24.   65146.58 requests per second
  25.   ====== SET ======
  26.     100000 requests completed in 1.63 seconds
  27.     50 parallel clients
  28.     3 bytes payload
  29.     keep alive: 1
  30.   99.24% <= 1 milliseconds
  31.   99.51% <= 2 milliseconds
  32.   99.64% <= 3 milliseconds
  33.   99.65% <= 5 milliseconds
  34.   99.65% <= 6 milliseconds
  35.   99.70% <= 10 milliseconds
  36.   99.87% <= 11 milliseconds
  37.   100.00% <= 11 milliseconds
  38.   61462.82 requests per second
  39.   ====== GET ======
  40.     100000 requests completed in 1.65 seconds
  41.     50 parallel clients
  42.     3 bytes payload
  43.     keep alive: 1
  44.   98.37% <= 1 milliseconds
  45.   99.40% <= 2 milliseconds
  46.   99.55% <= 8 milliseconds
  47.   99.60% <= 10 milliseconds
  48.   99.72% <= 11 milliseconds
  49.   99.98% <= 12 milliseconds
  50.   100.00% <= 12 milliseconds
  51.   60422.96 requests per second
  52.   ########  省略  ###########
  53.   ====== SADD ======
  54.     100000 requests completed in 1.58 seconds
  55.     50 parallel clients
  56.     3 bytes payload
  57.     keep alive: 1
  58.   99.15% <= 1 milliseconds
  59.   99.86% <= 2 milliseconds
  60.   99.90% <= 12 milliseconds
  61.   99.95% <= 16 milliseconds
  62.   99.99% <= 17 milliseconds
  63.   100.00% <= 17 milliseconds
  64.   63371.36 requests per second
  65.   ====== HSET ======
  66.     100000 requests completed in 1.65 seconds
  67.     50 parallel clients
  68.     3 bytes payload
  69.     keep alive: 1
  70.   98.95% <= 1 milliseconds
  71.   99.54% <= 2 milliseconds
  72.   99.65% <= 5 milliseconds
  73.   99.67% <= 6 milliseconds
  74.   99.70% <= 10 milliseconds
  75.   99.91% <= 11 milliseconds
  76.   100.00% <= 11 milliseconds
  77.   60642.81 requests per second
  78.   ########  省略  ###########
  79.   [root@RLKJ-BT ~]#
复制代码
如上,快速测试出的结果非常全,经过删减还有很多,我们比较关注的就是   100%   的时延和   QPS   。从上面的结果中我们大致能够得出被测   redis    的时延都在十几毫秒,  QPS    都在   6W   多,性能还是很好的。
  2、精简测试
  对于快速测试的结果,我们需要去分析挑选那我们需要的数据,其实   redis-benchmark   已经为我们提供了精简测试模式,我们是同-t 参数指定需要测试的操作类型就可以实现对指定操作的性能进行测试。
  例:对   set    和   get    进行   1000000   个请求的性能测试
  1.  [root@RLKJ-BT ~]# redis-benchmark -t set,get -n 1000000 -q
  2.   SET: 62774.64 requests per second
  3.   GET: 63195.14 requests per second
  4.   [root@RLKJ-BT ~]#
复制代码
如上,我们已经拿到了非常精简的数据,我们可以直接将其放到我们的测试报告中。
  3、Pipline 测试
  针对业务场景,我们可以通过   pipline    来模拟业务场景,批量提交命令给   redis server  ,从而提升性能。
  例:我们模拟每个   pipline    执行   10   次命令。
  1. [root@RLKJ-BT ~]# redis-benchmark -t set,get -n 1000000 -q -P 10
  2.   SET: 446229.38 requests per second
  3.   GET: 450450.44 requests per second
  4.   [root@RLKJ-BT ~]#
复制代码
 同样的请求数,你会发现单次执行多条命令的性能数据要比单次执行一条命令的性能数据高出7多。








欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2