An HTTP benchmarking tool - http_load (with examples)
- Linux
- November 5, 2023
Emulate 20 requests based on a given URL list file per second for 60 seconds:
http_load -rate 20 -seconds 60 path/to/urls.txt
Motivation:
This command is useful when we want to simulate a certain number of requests per second to test the throughput of a web server. By setting the rate to 20 requests per second, we can generate a moderate amount of traffic and observe how the server handles the load over a period of 60 seconds.
Explanation:
-rate 20
: Specifies the rate at which requests should be emulated, in this case, 20 requests per second.-seconds 60
: Sets the duration of the test to 60 seconds.path/to/urls.txt
: Specifies the path to a file containing the list of URLs to be fetched.
Example output:
Finished 20 / 20 fetches
20 fetches, 20 max parallel, 0.0658349 seconds
3333.55 fetches/sec, 0.00250249 ms/fetch
15 bytes/socket, 321 bytes/http1.1 req/resp, 4557.28 bytes/sec
Emulate 5 concurrent requests based on a given URL list file for 60 seconds:
http_load -parallel 5 -seconds 60 path/to/urls.txt
Motivation:
This command allows us to emulate a situation where multiple requests are being processed simultaneously by the web server. By setting the parallel value to 5, we can simulate concurrent traffic and observe how well the server handles concurrent requests over a 60-second period.
Explanation:
-parallel 5
: Sets the maximum number of concurrent requests to 5.-seconds 60
: Sets the duration of the test to 60 seconds.path/to/urls.txt
: Specifies the path to a file containing the list of URLs to be fetched.
Example output:
Finished 286 / 286 fetches
286 fetches, 5 max parallel, 0.734307 seconds
389.843 fetches/sec, 0.00256408 ms/fetch
15 bytes/socket, 321 bytes/http1.1 req/resp, 119659 bytes/sec
Emulate 1000 requests at 20 requests per second, based on a given URL list file:
http_load -rate 20 -fetches 1000 path/to/urls.txt
Motivation:
This command is useful when we want to generate a specific number of requests to a web server and observe its behavior under a fixed load. In this case, we set the rate to 20 requests per second and specify the total number of desired fetches as 1000. By doing so, we can analyze the server’s performance and response time when processing a large number of requests.
Explanation:
-rate 20
: Specifies the rate at which requests should be emulated, in this case, 20 requests per second.-fetches 1000
: Sets the total number of fetches to be emulated as 1000.path/to/urls.txt
: Specifies the path to a file containing the list of URLs to be fetched.
Example output:
Finished 1000 / 1000 fetches
1000 fetches, 20 max parallel, 0.391874 seconds
2552.88 fetches/sec, 0.000391874 ms/fetch
15 bytes/socket, 321 bytes/http1.1 req/resp, 101743 bytes/sec
Emulate 1000 requests at 5 concurrent requests at a time, based on a given URL list file:
http_load -parallel 5 -fetches 1000 path/to/urls.txt
Motivation:
This command allows us to emulate a situation where we want to generate a large number of requests to a web server, but limit the maximum number of concurrent requests at a time. By setting the parallel value to 5 and specifying 1000 fetches, we can study how the server handles a steady flow of concurrent requests without overwhelming its resources.
Explanation:
-parallel 5
: Sets the maximum number of concurrent requests to 5.-fetches 1000
: Sets the total number of fetches to be emulated as 1000.path/to/urls.txt
: Specifies the path to a file containing the list of URLs to be fetched.
Example output:
Finished 1000 / 1000 fetches
1000 fetches, 5 max parallel, 0.163561 seconds
6115.09 fetches/sec, 0.000234699 ms/fetch
15 bytes/socket, 321 bytes/http1.1 req/resp, 787384 bytes/sec
In conclusion, the http_load command is a versatile tool for benchmarking web servers by emulating various request scenarios. Whether it’s testing the server’s throughput, analyzing its response time under different loads, or studying its performance during concurrent requests, http_load provides a simple yet powerful solution to simulate and measure the behavior of a web server.