压测的时候,我们会经常关注2个重要的指标 TPS 和 RT,TPS 每秒处理的事务数(Transactions per Second),jmeter的Throughput为吞吐量(请求数/秒),TPS=并发数/响应时间;RT 响应时间(Reponse Time),从发起请求到完全接收到应答的时间消耗(平均响应时间)。我们在聚合报告里面能看到最后的测试结果TPS值(Throughput)和RT值(平均响应时间)。如果我们想查看更详细的报告,查看压测过程中不同时间段的每秒事务数,可以使用 Transactions per Second 插件来查看TPS,添加-监听器-jp@gc - Response Times Over Time插件查看RT。
jmeter自带插件不包含jp@gc -Transactions per Second 和jp@gc - Response Times Over Time插件,需要我们先下载Plugins Manager插件管理器后再添加这两个插件即可。
插件管理器Plugins Manager下载,下载地址https://jmeter-plugins.org/install/Install/

下载插件后把jar包放到 lib/ext 目录,然后重启jmeter。点击“选项”-“Plugins Manager”




设置线程数5,循环执行100次运行脚本,查看聚合报告吞吐量TPS:54.0/sec,Average平均响应时间RT:86ms

根据公式计算TPS=5/0.086=58.14/sec,计算的结果和吞吐量54/sec很接近;这样理解这个公式,绝对的并发是不存在的,请求发出的时间总有先后,绝对的TPS也是无法计算的,统计的角度看:TPS = 服务器处理请求总数/花费的总时间;我们设置线程组的持续压测时间为5秒,设置线程数5,于是压测的结果TPS值是39.18;根据公式TPS = 总请求数194/总时长5秒,得到的结果是38.8,这样就很接近报告的TPS值了;为了找到服务器的最大TPS值,我们一般设置不同的并发数(线程组)来压测。




网友评论