Using the loadtest command (with examples)
1: Run with concurrent users and a specified amount of requests per second
loadtest --concurrency 10 --rps 200 https://example.com
Motivation: This use case allows you to simulate a high load on your website by specifying the number of concurrent users and the number of requests per second. It can help you identify potential performance issues and determine if your infrastructure can handle the expected traffic.
Explanation:
--concurrency 10
: Specifies the number of concurrent users to simulate. In this example, we are simulating 10 concurrent users.--rps 200
: Specifies the number of requests per second to send. In this example, we are sending 200 requests per second.https://example.com
: The URL of the website or API endpoint to test.
Example Output:
Starting load test...
Finished load test: 200 requests, 10 concurrent users, 2.4s total time, 83.3ms avg response time
2: Run with a custom HTTP header
loadtest --headers "accept:text/plain;text-html" https://example.com
Motivation: This use case allows you to add custom HTTP headers to the requests sent during the load test. It can be useful for testing specific functionality that relies on certain headers being present in the requests.
Explanation:
--headers "accept:text/plain;text-html"
: Specifies the custom HTTP headers to include in the requests. In this example, we are adding two headers:accept:text/plain
andtext-html
.https://example.com
: The URL of the website or API endpoint to test.
Example Output:
Starting load test...
Finished load test: 1000 requests, 1 concurrent user, 5.2s total time, 5.2ms avg response time
3: Run with a specific HTTP method
loadtest --method GET https://example.com
Motivation: This use case allows you to specify a specific HTTP method (GET, POST, PUT, DELETE, etc.) to use for the requests during the load test. It can help you test specific API endpoints or simulate different types of requests.
Explanation:
--method GET
: Specifies the HTTP method to use for the requests. In this example, we are using the GET method.https://example.com
: The URL of the website or API endpoint to test.
Example Output:
Starting load test...
Finished load test: 500 requests, 10 concurrent users, 3.8s total time, 7.6ms avg response time
By using the loadtest command with different options, you can perform load tests with varying configurations such as concurrent users, requests per second, custom headers, and specific HTTP methods. This allows you to simulate different traffic scenarios and evaluate the performance and resilience of your web application or API.