JMeter 清除 JDBC 响应数据

JMeter Clear JDBC response data

我们目前运行 正在使用 JMeter 对数据库进行压力测试。我们正在发送一堆查询,数据库以每个查询的结果集作为响应。

当数据returns时,它保留在我们用来执行JMeter测试的机器的内存RAM中。我们不希望这样,因为它会填满内存,减慢测试速度,很快我们就会从 JVM 收到内存不足的错误。处理该问题的最佳方法是什么?

有没有办法将数据保存在某个csv文件中或清除内存RAM?我们并不真正关心 returns 的数据。我们只关心衡量性能。

JMeter 会自动从不再需要的资源中释放内存。所以看起来你的 运行 配置需要引用收到的结果。

如果您使用的是 View Results Tree,则应将其从 运行 配置中删除。

As stated in the documentation:

View Results Tree MUST NOT BE USED during load test as it consumes a lot of resources (memory and CPU). Use it only for either functional testing or during Test Plan debugging and Validation.

不行,我能想到的唯一方法就是调用JDBC statements via execute() function instead of executeQuery(), this way you will not get the ResultSet,这样JMeter的内存消耗会少一些。

可以通过两种方式实现

  1. 补丁AbstractJDBCTestElementclass
  2. 切换到 JSR223 Sampler and code your database load testing logic fully in Groovy, something like the approach described in the Cassandra Load Testing with Groovy 篇文章。