Jmeter 压测接口返回大量数据时吞吐量上不去问题记录

1. 背景介绍

近期需要对外部提供一个批量查询接口,接口逻辑并不复杂,只是返回的数据有点多。分页查询,最大查询100个单子,分页单页最大值没有限制,那么,极端情况下,就是一次查询100个单子,每个单子 6 种节点,每一个节点可以保存最大 10 张图片地址信息,单次查询最多返回 6K 条记录,大概72K。

由于是对外接口,必须要做压测,使用的工具是 jmeter,压测过程遇到了问题,解决过程中国走了不少弯路,所以,做下记录,也希望能帮到有同样问题的小伙伴。

2. 问题描述

压测执行脚本报错信息:

java 复制代码
org.apache.http.ConnectionClosedException: Premature end of chunk coded message body: closing chunk expected
	at org.apache.http.impl.io.ChunkedInputStream.getChunkSize(ChunkedInputStream.java:263)
	at org.apache.http.impl.io.ChunkedInputStream.nextChunk(ChunkedInputStream.java:222)
	at org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:183)
	at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:135)
	at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:148)
	at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.readResponse(HTTPSamplerBase.java:1936)
	at org.apache.jmeter.protocol.http.sampler.HTTPAbstractImpl.readResponse(HTTPAbstractImpl.java:476)
	at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:673)
	at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:66)
	at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1296)
	at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1285)
	at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:638)
	at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:558)
	at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:489)
	at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256)
	at java.lang.Thread.run(Thread.java:750)

显然,这是被压测接口返回数据量过大导致的。

查看压测的聚合报告,吞吐量很低,发送速率很低,并发量上不来。

3. 解决方案

压缩接口响应信息

3.1 请求头添加参数

html 复制代码
Accept-Encoding:gzip, deflate

3.2 springboot服务需要开启压缩

XML 复制代码
server: 
  port: 8080
  compression:
    enabled: true
    mime-types: application/json,application/xml,text/html,text/xml,text/plain
    min-response-size: 2048
    compression-level: 6

4. 尾记

问题解决,吞吐量飙升

相关推荐
banyoyo9 天前
jmeter测试使用方法
jmeter
汪汪88888810 天前
jmeter压测下载功能影响本地内存的方案
jmeter
跨境数据猎手11 天前
跨境电商系统JMeter 和 Gatling 分工
jmeter
han688912 天前
jmeter操作数据库
数据库·jmeter
川石课堂软件测试14 天前
涨薪技术|0到1学会性能测试第8课-Analysis分析图
服务器·数据库·python·sql·jmeter·mysql·容器
川石课堂软件测试14 天前
JMeter异步接口测试实战
数据库·python·jmeter·mysql·kubernetes·测试用例·prometheus
zuozewei16 天前
第02篇-k6-脚本结构与生命周期
软件测试·jmeter·性能测试·k6·ai 编程
fen_fen17 天前
Jmeter5.1.1连接oracle数据库的错误复盘
数据库·jmeter·oracle
川石课堂软件测试20 天前
自动化测试|持续集成Git使用详解
git·python·jmeter·mysql·ci/cd·容器·kubernetes
wuhuhuan22 天前
JMeter 连接数据库并取值(JDBC 实战)
数据库·jmeter