Redis-benchmark测试Redis性能
Redis-benchmark是官方自带的Redis性能测试工具,可以有效的测试Redis服务的性能。
使用说明如下:
Usage: 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) -c <clients> Number of parallel connections (default 50) -n <requests> Total number of requests (default 10000) -d <size> Data size of SET/GET value in bytes (default 2) -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 get/set keys in the form mykey_rand:000000012456 instead of constant keys, the <keyspacelen> argument determines the max number of values for the random number. For instance if set to 10 only rand:000000000000 - rand:000000000009 range will be allowed. -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.
测试命令事例:
1、redis-benchmark -h 192.168.1.201 -p 6379 -c 100 -n 100000
100个并发连接,100000个请求,检测host为localhost 端口为6379的redis服务器性能
2、redis-benchmark -h 192.168.1.201 -p 6379 -q -d 100
测试存取大小为100字节的数据包的性能
3、redis-benchmark -t set,lpush -n 100000 -q
只测试某些操作的性能
4、redis-benchmark -n 100000 -q script load "redis.call('set','foo','bar')"
只测试某些数值存取的性能
测试结果分析:
www@iZ23s8agtagZ:~$ redis-benchmark -h 121.41.88.209 -p 63789 -t lRange -c 10 ====== LPUSH (needed to benchmark LRANGE) ====== 10000 requests completed in 0.16 seconds 10 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 62111.80 requests per second ====== LRANGE_100 (first 100 elements) ====== 10000 requests completed in 0.26 seconds 10 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 39062.50 requests per second ====== LRANGE_300 (first 300 elements) ====== 10000 requests completed in 0.62 seconds 10 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 16051.36 requests per second ====== LRANGE_500 (first 450 elements) ====== 10000 requests completed in 0.91 seconds 10 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 10940.92 requests per second ====== LRANGE_600 (first 600 elements) ====== 10000 requests completed in 1.18 seconds 10 parallel clients 3 bytes payload keep alive: 1 99.35% <= 1 milliseconds 99.88% <= 2 milliseconds 99.91% <= 4 milliseconds 100.00% <= 4 milliseconds 8474.58 requests per second
测试结果2:
www@iZ23s8agtagZ:~$ redis-benchmark -h 121.41.88.209 -p 63789 -t lRange -c 10 -q LPUSH (needed to benchmark LRANGE): 64102.56 requests per second LRANGE_100 (first 100 elements): 39370.08 requests per second LRANGE_300 (first 300 elements): 16694.49 requests per second LRANGE_500 (first 450 elements): 11001.10 requests per second LRANGE_600 (first 600 elements): 8319.47 requests per second
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· dotnet 源代码生成器分析器入门
· ASP.NET Core 模型验证消息的本地化新姿势
· 对象命名为何需要避免'-er'和'-or'后缀
· SQL Server如何跟踪自动统计信息更新?
· AI与.NET技术实操系列:使用Catalyst进行自然语言处理
· dotnet 源代码生成器分析器入门
· 官方的 MCP C# SDK:csharp-sdk
· 一款 .NET 开源、功能强大的远程连接管理工具,支持 RDP、VNC、SSH 等多种主流协议!
· 提示词工程师自白:我如何用一个技巧解放自己的生产力
· 一文搞懂MCP协议与Function Call的区别