如何在 Jmeter 中为 500 个并发用户设置加速时间?

How to setup ramp up time in Jmeter for 500 concurrent users?

我们想证明我们的客户 REST API 可以处理 500 个并发请求。为了实现这一点,设置加速时间的最佳方法是什么?

  1. 1 秒内有 500 个请求吗?
  2. 5 秒内 2500 个请求?
  3. 还有其他选择吗?

对于第一个选项,应用程序和网络服务器将被淹没。有第二个选项 我应该如何设置它?

感谢对此的任何意见。

其实性能测试有很多不同的面,例如:

  • Load Testing: the process of verifying whether the application under test can handle anticipated load, if you expect 500 users - set 500 threads under Thread Group and configure Ramp-Up period so the load would increase gradually. According to JMeter documentation:

    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.

    因此,如果您有 500 秒的启动时间,所​​有 500 个用户将在约 8 分钟内在线,之后您可以离开测试 运行 一段时间(即另外 500 秒),然后 再次逐渐(再过 500 秒)将负载减少到零。

    这样您就可以将增加的响应时间(或增加的错误数量)与增加的负载相关联,反之亦然。

  • Soak Testing: basically the same as above, but leave the test running overnight or over the weekend to see how does your application survives the prolonged load. This way you will be able to detect for example memory leaks

  • Stress Testing:同样与负载测试相同,但不要将最大负载限制为 500 个用户,逐渐增加负载直到您的应用程序中断,看看有多少 最多 个用户可以服务。那你可能也想逐渐降低负载,看看当负载恢复正常时它是否恢复

  • Spike Testing:这不假设任何加速,这样您将测试您的应用程序如何处理 500 个用户同时到达

请参阅 Why ‘Normal’ Load Testing Isn’t Enough 文章,了解有关各种性能测试类型的更详细说明以及您需要考虑所有这些类型的原因。