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. 尾记

问题解决,吞吐量飙升

相关推荐
@汤圆酱3 小时前
【无标题】
python·jmeter
CesareCheung3 小时前
Jmeter压测时如何设置只登录一次后压其他的接口
jmeter·性能优化
江上月5131 天前
JMeter入门实战指南:从环境搭建到首次压测
jmeter
Wpa.wk1 天前
性能测试工具 - JMeter工具组件介绍二
运维·经验分享·测试工具·jmeter·自动化·json
Wpa.wk1 天前
性能测试工具 - JMeter工具组件介绍一
java·经验分享·测试工具·jmeter·性能测试
shughui4 天前
JMter(六):jmete变量提取常用方式
jmeter·性能优化
大霞上仙4 天前
jmeter 两个循环控制器的使用例子
jmeter
张永清-老清4 天前
每周读书与学习->JMeter性能测试脚本编写实战(三)如何利用JMeter为MySQL数据库构造测试数据
数据库·测试工具·jmeter·压力测试·性能调优·jmeter性能测试·每周读书与学习
周末吃鱼5 天前
研发快速使用JMeter
java·jmeter
shughui7 天前
JMeter(一):jemter安装
jmeter