在 JMETER 中 - 如何在 API 测试的每个单独请求级别实现 TPS

In JMETER - How to achieve TPS at each individual request level for API testing

I would like to achieve transactions per minutes at request level, what would be approach and how the script structure should look like ?

要求:

我总共有 67 个并发用户。

I need to achieve transaction per minute at each request level, all under same thread group. As per my requirement, my each HTTP sampler is a transaction. This is for API testing.

6 API requests under 6 simple controller. 

My Script structure:
1. Test Plan
2. Thread Group
3. Simple Controller
    i. HTTP Sampler
    ii. Response Assertion.
    iii. Boundary value Extractor
    iv. Results Action Set Handler
4. View Results Tree
5. Summary Report

I have tried 2 ways:

Instead of simple controller, i have used throughput controller and used percent Executions.

I also had constant throughput timer.

Requirement:
In total i have 67 concurrent users.

I need to achieve transaction per minute at each request level, all under same thread group.

6 API requests under 6 simple controller.

My Script structure:

1. Test Plan
2. Thread Group
3. Simple Controller
    i. HTTP Sampler
    ii. Response Assertion.
    iii. Boundary value Extractor
    iv. Results Action Set Handler
4. View Results Tree
5. Summary Report

Example:    
All API requests / http sampler falls under the same thread group and request should execute in the given sequence as correlation is in place.

API 每分钟请求 1 - 152 个请求。 API 每分钟请求 2 - 56 个请求。 API 每分钟请求 3 - 32 个请求。 API 每分钟请求 4 - 12 个请求。 API 每分钟请求 5 - 12 个请求。 API 每分钟请求 6 - 12 个请求。

Were i need to perform a load test and soak test as well with the above workload model.

您不能为不同的 Samplers under the same Thread Group 设置不同的吞吐量级别,因为 JMeter 会颠倒执行采样器并循环执行,因此总执行速度将被限制为最慢采样器的执行速率。

解决方法是将你想要以不同速度执行的请求放在不同的线程组中。如果您需要在不同线程组中的线程之间传递值,您可以使用:

  1. __setProperty() function in 1st Thread Group to save the needed value(s) into a JMeter property(ies) and __P() function in 2nd Thread Group to read the value. You might also want to combine it with __threadNum() function 使值特定于线程。
  2. Inter-Thread Communication Plugin

反过来,您可以使用以下测试元素之一来为不同线程组下的采样器设置所需的 TPS:

  1. Constant Throughput Timer
  2. Precise Throughput Timer
  3. Throughput Shaping Timer