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

JMeter压测场景配置咨询:每20秒增1个用户每5秒ping服务器持续24小时

Alright, let's walk through exactly how to set up this load testing scenario in JMeter. I’ve configured similar gradual ramp-up and sustained load tests before, so this should fit your requirements perfectly.

1. Install Required Plugins (If Needed)

First, if you don’t already have it, grab the Custom Thread Groups plugin via the JMeter Plugins Manager. The Stepping Thread Group included here is perfect for your "add 1 user every 20 seconds" requirement—way easier than cobbling together timers with a regular thread group.

2. Configure the Thread Group (User Scheduling)

Add the Stepping Thread Group to your test plan, then set these parameters:

  • Start Threads Count: 0 (start with no users)
  • Initial Delay, sec: 0 (kick off the test immediately)
  • Startup Time, sec: 20 (wait 20 seconds between each batch of users)
  • Startup Threads Count: 1 (add exactly 1 user per batch)
  • Total Threads: 1000 (stop adding users once we hit 1000 total)
  • Hold Load For, sec: 86400 (keep 1000 users running for 24 hours straight)
  • Shutdown Time, sec: 0 (optional—shutdown all users immediately once the 24 hours are up)

This setup will slowly ramp up your user count over ~5 hours 33 minutes (1000 users × 20 seconds), then maintain full load for the full 24-hour window.

3. Set Up the Ping Action Per User

Each user needs to ping your server every 5 seconds. Here are two reliable ways to implement this:

Add a TCP Sampler under the thread group—this avoids relying on OS-specific ping commands:

  • Server Name or IP: Your target server’s IP or domain name
  • Port: Pick an open port on your server (e.g., 80 for HTTP, 443 for HTTPS)
  • Timeout (ms): 5000 (wait 5 seconds for a response before marking it as failed)
  • Text to send: For HTTP ports, send a minimal request like:
    GET / HTTP/1.1\r\nHost: your-server-domain.com\r\n\r\n
    

3.2 Option 2: OS Process Sampler (True ICMP Ping)

If you need a real ICMP ping (not just a TCP connection test), use the OS Process Sampler:

  • Command: ping (Windows) or ping (Linux/macOS)
  • Command parameters:
    • Windows: -n 1 your-server-ip (send 1 ping packet per execution)
    • Linux/macOS: -c 1 your-server-ip (same as above, but Unix-style syntax)

3.3 Add a Timer to Control Ping Interval

To make each user ping every 5 seconds, add a Constant Timer directly under the thread group (it will apply to all samplers in the group):

  • Thread Delay (in milliseconds): 5000 (wait 5 seconds after each ping before running the next one)

Note: This timer adds a delay after each request. If you want the first ping to wait 5 seconds too, you can add an extra Test Action Sampler with a 5-second delay at the start of the thread group.

4. Add Listeners to Monitor Results

Don’t forget to add listeners to track how your test is performing:

  • Summary Report: Get high-level stats like average response time, error rate, and throughput
  • View Results Tree: For debugging (disable this in full load tests to save resources)
  • Aggregate Graph: Visualize response times and error rates over time
  • If you’re running for 24 hours, consider a Backend Listener to send metrics to a tool like InfluxDB + Grafana—this makes it easier to analyze trends without digging through huge log files.
5. Pre-Test Validation

Before running the full 24-hour test, do a quick sanity check:

  • Set Total Threads to 2, Hold Load For to 60 seconds, and run the test. Verify that:
    1. A new user starts every 20 seconds
    2. Each user sends a ping every 5 seconds
    3. Responses are being recorded correctly
Key Notes for Stability
  • JMeter Heap Memory: Edit your jmeter.bat (Windows) or jmeter.sh (Linux/macOS) to increase heap size—for 1000 threads, try HEAP="-Xms2g -Xmx6g" (adjust based on your machine’s RAM)
  • OS Permissions: If using the OS Process Sampler, make sure the user running JMeter has permission to execute the ping command
  • Resource Monitoring: Keep an eye on JMeter’s CPU/memory usage during the test—if it starts choking, you might need to distribute the load across multiple JMeter instances

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.27 09:26:02