如何执行Redis基准测试()

本文概述

  • Redis基准
  • Redis-cli
  • Memtier基准
  • RDB工具
使用以下出色的工具, 了解Redis的性能, 中断时间, 吞吐量, 数据传输速率等。
在过去的几年中, Redis(远程词典服务)的流行和使用量有所增加。
如何执行Redis基准测试()

文章图片
不仅适用于企业应用程序, 而且也适用于中小型企业。甚至, 你可以在WordPress上使用Redis进行缓存, 并且性能要好得多。如果有兴趣从头开始学习Redis, 请查看此在线课程。
作为企业应用程序的开发人员或系统管理员, 你应了解执行基准测试以了解应用程序的性能和容量。 Redis基准测试与Web服务器略有不同。好消息是, 有许多免费工具可用, 因此你可以选择最适合自己的工具。
准备探索吗?
Redis基准测试工具
  • Redis基准
  • Redis-cli
  • Memtier基准
  • RDB工具
Redis基准 利用Redis内置的基准测试实用程序redis-benchmark。它包含在Redis安装中, 只需在UNIX上键入redis-benchmark即可执行。它在Windows上也可用, 可执行文件是redis-benchmark.exe。
让我们来看以下示例。
针对192.168.0.100发送一百万个请求
[email  protected]:~# redis-benchmark -h 192.168.0.100 -p 6379 -n 1000000====== PING_INLINE ======1000000 requests completed in 30.62 seconds50 parallel clients3 bytes payloadkeep alive: 161.85% < = 1 milliseconds99.55% < = 2 milliseconds99.93% < = 3 milliseconds99.96% < = 4 milliseconds99.98% < = 5 milliseconds99.99% < = 6 milliseconds99.99% < = 7 milliseconds100.00% < = 8 milliseconds100.00% < = 9 milliseconds100.00% < = 9 milliseconds32653.06 requests per second

30.62秒内完成了100万个请求。还要注意最后一行, 每秒处理约32653个请求。
如果仔细看, 有效负载大小为3个字节。这是默认设置, 可以使用-d参数进行自定义。以下测试适用于有效负载为1mb的100k请求。
[email  protected]:~# redis-benchmark -h 127.0.0.1 -p 6379 -n 100000 -d 1000000====== PING_INLINE ======100000 requests completed in 2.80 seconds50 parallel clients1000000 bytes payloadkeep alive: 173.19% < = 1 milliseconds99.95% < = 2 milliseconds100.00% < = 2 milliseconds35676.06 requests per second

你注意到并行客户端了吗?它的默认值是50并进行调整, 可以使用-c参数。下面的示例适用于200个客户端。
[email  protected]:~# redis-benchmark -h 127.0.0.1 -p 6379 -n 100000 -d 1000000 -c 200====== PING_INLINE ======100000 requests completed in 3.77 seconds200 parallel clients1000000 bytes payloadkeep alive: 10.00% < = 1 milliseconds2.99% < = 2 milliseconds18.95% < = 3 milliseconds45.81% < = 4 milliseconds69.65% < = 5 milliseconds86.58% < = 6 milliseconds95.79% < = 7 milliseconds98.88% < = 8 milliseconds99.78% < = 9 milliseconds99.96% < = 10 milliseconds100.00% < = 10 milliseconds26532.24 requests per second

如你所见, 有200个客户, 这花费了更多时间, 处理速度也变慢了。但是, 这是意料之中的, 这有助于找到应用程序的真实性能。
对Redis基准工具不满意?不用担心, 还有以下内容。
Redis-cli 只对延迟信息感兴趣吗?
当然, 你可以使用Redis服务器随附的redis-cli。你可以使用– latency参数执行。
[email  protected]:~# redis-cli --latencymin: 0, max: 1, avg: 0.16 (1056 samples

缺省情况下, 延迟样本为每秒, 但你可以根据需要使用-i开关进行更改。
Memtier基准 Redis Labs的Memtier基准测试同时支持Redis和Memcache。它是一个高级基准测试工具, 具有以下各种测试选项。
  • 测试密码保护的Redis
  • 在集群模式下运行客户端
  • 提供客户端数量, 请求, 线程, 数据大小,
  • 调整设置和获取比例
还有更多……
这是一份快速测试报告。
[email  protected]:~# memtier_benchmark [RUN #1] Preparing benchmark client...[RUN #1] Launching threads now...[RUN #1 100%, 133 secs]3 threads:1993223 ops, 15083 (avg:14877) ops/sec, 639.97KB/sec (avg: 631.04KB/sec), 13.30 (avg: 13.44) msec latenc[RUN #1 100%, 134 secs]0 threads:2000000 ops, 15083 (avg:14911) ops/sec, 639.97KB/sec (avg: 632.52KB/sec), 13.30 (avg: 13.41) msec latency4Threads50Connections per thread10000Requests per clientALL STATS=========================================================================TypeOps/secHits/secMisses/secLatencyKB/sec -------------------------------------------------------------------------Sets1354.30------13.40200104.30 Gets13528.130.0013528.1313.41000526.98 Waits0.00------0.00000--- Totals14882.430.0013528.1313.40900631.28 Request Latency DistributionType< = msecPercent------------------------------------------------------------------------SET0.0550.00SET0.0630.00SET0.1100.00SET0.1400.00SET0.1600.00SET0.1700.00SET0.1800.00SET0.2100.01SET0.2300.01SET0.2800.01SET0.3000.01SET0.3600.01SET0.4400.01SET0.4600.01SET0.4800.01SET0.5100.01SET0.5700.01SET0.5900.01SET0.6100.01SET0.6300.01SET0.6400.02SET0.6700.02SET0.6800.02SET0.7100.02SET0.7300.02SET0.7400.02SET0.7500.02SET0.7600.02SET0.7700.02SET0.7800.02SET0.7900.02SET0.8200.02SET0.8400.02SET0.8500.03SET0.8700.03SET0.8800.03SET0.9000.03SET0.9300.03SET0.9400.03SET0.9500.03SET0.9600.03SET0.9700.03SET1.0000.03SET1.1000.04SET1.2000.05SET1.3000.06SET1.4000.07SET1.5000.08SET1.6000.08SET1.7000.09SET1.8000.10SET1.9000.10SET2.0000.11SET2.1000.12SET2.2000.12SET2.3000.13SET2.4000.14SET2.5000.16SET2.6000.18SET2.7000.21SET2.8000.24SET2.9000.25SET3.0000.26SET3.1000.27SET3.2000.28SET3.3000.28SET3.4000.29SET3.5000.30SET3.6000.32SET3.7000.35SET3.8000.37SET3.9000.39SET4.0000.42SET4.1000.45SET4.2000.48SET4.3000.52SET4.4000.55SET4.5000.59SET4.6000.63SET4.7000.68SET4.8000.73SET4.9000.77SET5.0000.82SET5.1000.88SET5.2000.93SET5.3000.99SET5.4001.06SET5.5001.12SET5.6001.18SET5.7001.25SET5.8001.33SET5.9001.40SET6.0001.47SET6.1001.56SET6.2001.64SET6.3001.73SET6.4001.81SET6.5001.92SET6.6002.00SET6.7002.10SET6.8002.21SET6.9002.32SET7.0002.44SET7.1002.57SET7.2002.69SET7.3002.80SET7.4002.95SET7.5003.09SET7.6003.24SET7.7003.37SET7.8003.52SET7.9003.68SET8.0003.84SET8.1004.02SET8.2004.17SET8.3004.34SET8.4004.49SET8.5004.65SET8.6004.84SET8.7005.03SET8.8005.20SET8.9005.38SET9.0005.59SET9.1005.78SET9.2006.01SET9.3006.22SET9.4006.45SET9.5006.72SET9.6007.05SET9.7007.35SET9.8007.66SET9.9007.99SET10.00010.29SET11.00017.47SET12.00039.07SET13.00062.05SET14.00076.14SET15.00083.95SET16.00088.77SET17.00091.73SET18.00093.54SET19.00094.82SET20.00095.90SET21.00096.80SET22.00097.62SET23.00098.26SET24.00098.74SET25.00099.07SET26.00099.31SET27.00099.49SET28.00099.65SET29.00099.71SET30.00099.76SET31.00099.82SET32.00099.86SET33.00099.89SET34.00099.91SET35.00099.93SET36.00099.96SET37.00099.97SET38.00099.98SET39.00099.99SET40.00099.99SET41.00099.99SET42.000100.00SET43.000100.00SET45.000100.00SET46.000100.00---GET0.0530.00GET0.0540.00GET0.0550.00GET0.0670.00GET0.0680.00GET0.0760.00GET0.0820.00GET0.0860.00GET0.1000.00GET0.1100.00GET0.1200.00GET0.1300.00GET0.1400.00GET0.1500.00GET0.1600.00GET0.1700.00GET0.1900.00GET0.2000.00GET0.2100.00GET0.2200.00GET0.2300.00GET0.2400.00GET0.2500.00GET0.2700.00GET0.2800.00GET0.2900.00GET0.3000.00GET0.3200.00GET0.3300.00GET0.3400.00GET0.3500.01GET0.3600.01GET0.3800.01GET0.4000.01GET0.4300.01GET0.4400.01GET0.4600.01GET0.4700.01GET0.4800.01GET0.5000.01GET0.5100.01GET0.5200.01GET0.5300.01GET0.5400.01GET0.5500.01GET0.5600.01GET0.5800.01GET0.5900.01GET0.6000.01GET0.6100.01GET0.6200.01GET0.6300.01GET0.6400.01GET0.6500.01GET0.6600.01GET0.6700.01GET0.6800.01GET0.6900.01GET0.7000.01GET0.7100.01GET0.7200.01GET0.7300.01GET0.7400.01GET0.7500.01GET0.7600.01GET0.7700.01GET0.7800.01GET0.7900.01GET0.8000.01GET0.8100.01GET0.8200.01GET0.8300.01GET0.8400.01GET0.8500.02GET0.8600.02GET0.8700.02GET0.8800.02GET0.8900.02GET0.9000.02GET0.9100.02GET0.9200.02GET0.9300.02GET0.9400.02GET0.9500.02GET0.9600.02GET0.9700.02GET0.9800.02GET0.9900.02GET1.0000.02GET1.1000.02GET1.2000.03GET1.3000.04GET1.4000.04GET1.5000.05GET1.6000.05GET1.7000.05GET1.8000.06GET1.9000.06GET2.0000.07GET2.1000.07GET2.2000.08GET2.3000.09GET2.4000.09GET2.5000.11GET2.6000.13GET2.7000.16GET2.8000.18GET2.9000.20GET3.0000.20GET3.1000.21GET3.2000.21GET3.3000.22GET3.4000.24GET3.5000.25GET3.6000.26GET3.7000.28GET3.8000.31GET3.9000.33GET4.0000.36GET4.1000.39GET4.2000.43GET4.3000.46GET4.4000.49GET4.5000.53GET4.6000.57GET4.7000.61GET4.8000.65GET4.9000.69GET5.0000.73GET5.1000.78GET5.2000.83GET5.3000.89GET5.4000.95GET5.5001.01GET5.6001.08GET5.7001.14GET5.8001.21GET5.9001.30GET6.0001.37GET6.1001.45GET6.2001.54GET6.3001.62GET6.4001.71GET6.5001.80GET6.6001.90GET6.7001.99GET6.8002.10GET6.9002.21GET7.0002.33GET7.1002.45GET7.2002.56GET7.3002.67GET7.4002.80GET7.5002.94GET7.6003.08GET7.7003.22GET7.8003.36GET7.9003.51GET8.0003.66GET8.1003.83GET8.2003.99GET8.3004.17GET8.4004.32GET8.5004.49GET8.6004.67GET8.7004.84GET8.8005.00GET8.9005.18GET9.0005.37GET9.1005.58GET9.2005.78GET9.3006.00GET9.4006.25GET9.5006.53GET9.6006.82GET9.7007.11GET9.8007.41GET9.9007.77GET10.00010.13GET11.00017.36GET12.00039.32GET13.00062.21GET14.00076.31GET15.00083.98GET16.00088.82GET17.00091.71GET18.00093.50GET19.00094.77GET20.00095.84GET21.00096.76GET22.00097.58GET23.00098.22GET24.00098.73GET25.00099.07GET26.00099.32GET27.00099.51GET28.00099.66GET29.00099.73GET30.00099.78GET31.00099.83GET32.00099.87GET33.00099.90GET34.00099.92GET35.00099.94GET36.00099.96GET37.00099.97GET38.00099.98GET39.00099.99GET40.00099.99GET41.00099.99GET42.000100.00GET43.000100.00GET44.000100.00GET45.000100.00GET46.000100.00GET47.000100.00---[email  protected]:~#

我怀疑你是否可以在Windows上安装此程序, 但可以肯定在UNIX发行版(如RHEL / CentOS, Ubuntu / Debian, MacOS等)上进行安装。可以免费尝试体验。
RDB工具 既可以用作CLI也可以用作GUI。 RDBTools是一个跨平台工具, 旨在帮助提高应用程序性能。在谈到特定于基准测试时, 它具有内存分析功能, 该功能可以调查内存使用情况, 关键分析, 识别内存泄漏并建议降低内存使用率。
如何执行Redis基准测试()

文章图片
你可以通过GUI查看实时性能并执行各种管理任务。
总结
【如何执行Redis基准测试()】希望以上工具能帮助你执行Redis基准测试, 以便你了解应用程序性能。

    推荐阅读