You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

JMeter多场景并发下实现指定每小时事务数的恒定吞吐量方法及最佳实践咨询

How to Achieve Target Transactions Per Hour in JMeter & Best Practices

Hey there! Let's break down how to solve your throughput control issue and share some key best practices for your end-to-end performance testing.

1. Implementing Target Transactions Per Hour for Each Scenario

Your current setup with separate thread groups for each scenario is a solid foundation. The key to controlling time-based throughput is combining the Constant Throughput Timer with wrapping your full business flow in a Transaction Controller. Here's the step-by-step setup:

Step 1: Wrap Each Scenario's Full Flow in a Transaction Controller

For both your Online Payment and Cash On Delivery thread groups:

  • Add a Transaction Controller as the parent element for all samplers and timers in the thread group.
  • Check the box: "Include duration of timer and pre/post processors in generated sample" — this ensures think times are included in the transaction duration, matching your definition of "1 transaction = full API flow including think time".

Step 2: Add Constant Throughput Timer to Each Thread Group

In each thread group, add a Constant Throughput Timer (under the Timers menu):

  • For Online Payment Thread Group:
    • Set Throughput to 100
    • Select Throughput based on as Per hour
    • Choose Calculate throughput based on as This thread group — this restricts the throughput control to only this scenario.
  • For Cash On Delivery Thread Group:
    • Set Throughput to 50
    • Select Throughput based on as Per hour
    • Choose Calculate throughput based on as This thread group

This configuration will enforce exactly the number of transactions per hour you need for each scenario. Your thread counts (30 and 10) are more than sufficient to support these throughputs — each thread will only execute a few transactions per hour, with idle time managed automatically by the timer.

Note: The Throughput Controller you tried earlier is designed for percentage-based or total-execution control, not time-based throughput. The Constant Throughput Timer is the correct tool for your hourly transaction targets.

2. Best Practices for End-to-End JMeter Performance Testing

Here are critical practices to make your tests realistic, reliable, and easy to maintain:

  • Parameterize All Dynamic Data:
    • Don’t hardcode login credentials, product IDs, or search terms. Use CSV Data Set Config to load unique user accounts, product lists, etc. This mimics real user behavior and avoids duplicate requests that skew results.
  • Use Realistic Think Times:
    • Replace fixed Constant Timer with Uniform Random Timer to simulate natural user pauses (e.g., a range of 2-5 seconds instead of a fixed 3 seconds). This makes your load pattern far more authentic.
  • Add Assertions to Validate Success:
    • For every critical step (Login, Payment Confirmation, Logout), add a Response Assertion to check for success status codes (like 200 OK) or specific response text. This ensures you only count valid, successful transactions in your results.
  • Optimize Listener Usage:
    • Avoid running View Results Tree during full load tests — it eats up excessive memory and CPU. Use Summary Report or Aggregate Report for real-time stats, and save results to a CSV file for post-test analysis.
  • Keep Test Plans Organized:
    • Use logic controllers (like Transaction Controllers) to group related steps, and add comments to document each part of your test plan. This makes maintenance much easier as your tests grow.
  • Monitor Target Server Resources:
    • Alongside JMeter metrics, track the target server’s CPU, memory, disk I/O, and network usage (using tools like top, sar, or cloud monitoring dashboards). This helps you correlate JMeter results with server performance to identify bottlenecks.
  • Validate Setup Before Full Execution:
    • Run a small test (e.g., 1 user, 1 transaction per scenario) to confirm all steps work, assertions pass, and throughput behaves as expected. This catches configuration errors early, saving you time later.

内容的提问来源于stack exchange,提问作者Dileep17

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.27 15:37:40