为什么 NodeJS API 的响应时间曲线在负载下会变成正弦曲线?

Why does the response time curve of NodeJS API become sinus like under load?

我目前正在使用 JMeter 在我的 NodeJS API 上执行 API 负载测试,我是这个领域的新手。 API 部署在具有 4 个 vCPU 和 8GB RAM 的 IBM 虚拟服务器上。 我的一项负载测试包括在 2500 个线程(用户)配置中对 API 进行压力测试,在无限循环中的启动时间为 2700 毫秒(45 分钟)。目标不是达到 2500 个线程,而是查看我的 API 会在什么时候抛出第一个错误。 我只在我的 API 上测试一个端点,它执行冒泡排序来模拟一项 CPU 密集型任务。我使用 Matplotlib 绘制了实验结果。我在活动线程上绘制了以毫秒为单位的响应时间。

我不确定为什么一旦跨越大约 1100 个线程,响应时间曲线就会变成 正弦曲线 。我预计响应时间曲线会以与开始时相同的方式继续上升(0 - 1100 个线程)。是否有关于曲线接近尾部的 正弦曲线 行为的解释?

谢谢!

图表:

红色 - 错误

蓝色 - 响应时间

这可能有 2 个可能的原因:

  1. 您的应用程序无法处理如此大的负载并频繁执行 garbage collection in order to free up resources or tasks are queuing up as application cannot process them as they come. You can try using i.e. JMeter PerfMon Plugin 以确保被测系统不缺少 CPU 或 RAM
  2. 如果需要,JMeter 默认会提供相对较低的 JVM Heap size and a very little GC tuning (like it's described in Concurrent, High Throughput Performance Testing with JMeter article where the guy has very similar symptoms) so it might be the case JMeter cannot send requests fast enough, make sure to follow JMeter Best Practices and consider going for distributed testing