如何在不等待服务器响应的情况下发送http请求

How to send http request without waiting for response from server

我们正计划对我们的服务器进行负载测试,我们需要从 Jmeter 工具生成高负载。但据我所知,jmeter 等待响应以创建另一个请求线程。有没有一种方法可以创建 http 请求而无需使用 jmeter 等待服务器的响应?如果不是,有什么可用的解决方法来生成重负载并保持线程数固定?

  1. HTTP Request sampler (or even better in HTTP Request Defaults 中定义一个非常小的超时,以便该设置将应用于所有 HTTP 请求采样器)比如 1 毫秒,这样 JMeter 将在发送请求后立即关闭连接

  2. (可选)为避免 JMeter 将请求标记为失败添加 Response Assertion 并勾选 Ignore Status

您可以在 HTTP Request 的 Advanced 选项卡中设置 Timeout of Connect and Response with 1 ms

Connect Timeout Connection Timeout. Number of milliseconds to wait for a connection to open.

Response Timeout Response Timeout. Number of milliseconds to wait for a response. Note that this applies to each wait for a response.

如果你需要return总是成功你可以添加JSR223 PostProcessor and use prev变量:

prev.setSuccessful(true)