做性能测试时并发请求的意义?

Meaning of concurrent request when doing performance testing?

我正在使用 node.js loadtest lib 来加载测试我的网站之一。

发送请求时的命令: loadtest -c 10 --rps 10 -t 30 www.example.com

其中 -c 表示并发性和 --rps 每秒请求数。

并发在文档中描述如下:

loadtest will create a certain number of clients; this parameter controls how many requests from them will arrive concurrently to the server. Note: requests are not sent in parallel (from different processes), but concurrently (a second request may be sent before the first has been answered).

-c 10 --rps 10是不是表示一共会和服务器建立10个连接,每个连接一秒发送1个请求?

调查documentation

1。 >-c-concurrency > >loadtest会创建一定数量的客户端;这个参数控制多少。来自它们的请求将同时到达服务器。 > >注意:请求不是并行发送(来自不同的进程),而是同时发送(第二个请求可能在第一个请求得到答复之前发送)。

  1. --rps requestsPerSecond

    Controls the number of requests per second that are sent. Can be fractional, e.g. --rps 0.5 sends one request every two seconds.

    Note: Concurrency doesn't affect the final number of requests per second, since rps will be shared by all the clients. E.g.:

    loadtest -c 10 --rps 10

    will send a total of 10 rps to the given URL, from 10 different clients (each client >will send 1 request per second).

    Beware: if concurrency is too low then it is possible that there will not be enough clients to send all of the rps, adjust it with -c if needed.

    Note: --rps is not supported for websockets.

所以:

  • -c 代表并发连接(虚拟用户),对于您的 -c 10 这意味着负载测试将使用 10 个并发线程以尽可能快的速度执行请求
  • -rps代表“requests per second”,如果你不希望这10个用户尽可能快地执行请求——你可以将每秒请求数限制为给定值。请记住,使用 rps 参数您只能 暂停 线程以将请求率限制在所需数量,负载测试不会自动添加更多线程来达到和维持所需数量每秒请求数,因此请确保提供足够数量的客户端

更多信息:What is the Relationship Between Users and Hits Per Second?