Apache JMeterJmeter性能测试工具软件测试

小白学JMeter:如何开始简单的WEB压力测试(二)

2018-01-29  本文已影响83人  LinJunF00lish

并发请求与参数化

在本小节中我们将通过一个实例演示如何并发多个POST请求,并且从CSV文件中读取POST请求的参数值。

1. 设置并发数与Ramp-up时间

上一节已经通过Thread Group配置了一个模拟用户发送HTTP请求的测试计划,通过Thread Group的参数设置我们可以模拟并发多个用户执行同样的测试计划:

Thread Group并发参数设置 通过增加Threads,可以增加并发的用户数。通过调整Ramp-up Period,可以控制并发请求发起的时间。如上图例子所示,在10秒内并发5个用户,即每隔2秒增加一个用户。一般一开始Ramp-up时间与Thread保持一致,即每1秒增加一个用户,然后再根据实际情况进行微调。

关于Ramp-up Period的具体解释可以参见官网手册的介绍:

The ramp-up period tells JMeter how long to take to "ramp-up" to the full number of threads chosen. If 10 threads are used, and the ramp-up period is 100 seconds, then JMeter will take 100 seconds to get all 10 threads up and running. Each thread will start 10 (100/10) seconds after the previous thread was begun. If there are 30 threads and a ramp-up period of 120 seconds, then each successive thread will be delayed by 4 seconds.
Ramp-up needs to be long enough to avoid too large a work-load at the start of a test, and short enough that the last threads start running before the first ones finish (unless one wants that to happen).
Start with Ramp-up = number of threads and adjust up or down as needed.

2. 从CSV文件读取参数

前面演示了如何发起GET请求。接下来在这里会演示如何发起多个POST请求,并且每个POST请求的参数都来自于CSV文件中。


上一篇 下一篇

猜你喜欢

热点阅读