LinuxCommandLibrary

loadtest

Simulate user load on a web server

TLDR

Run with concurrent users and a specified amount of requests per second

$ loadtest [[-c|--concurrency]] [10] [[--rps|--requestsPerSecond]] [200] [https://example.com]
copy

Run with a custom HTTP header
$ loadtest --headers "[accept:text/plain;text-html]" [https://example.com]
copy

Run with a specific HTTP method
$ loadtest [[-m|--method]] [GET] [https://example.com]
copy

SYNOPSIS

loadtest [-n requests] [-c concurrency] [options] URL

PARAMETERS

-n requests
    Total number of requests to perform during the test.

-c concurrency
    The number of concurrent requests or virtual users to simulate.

-p file
    Path to a file containing data to be sent in the request body (e.g., for POST requests).

-T type
    Sets the Content-Type header for requests, especially useful for POST data (e.g., "application/json").

-m method
    Specifies the HTTP method to use for requests (e.g., GET, POST, PUT, DELETE).

-t seconds
    Sets a timeout for each individual request in seconds.

-H header
    Adds a custom HTTP header to all requests (e.g., "Authorization: Bearer token"). Can be used multiple times.

-A user:pass
    Provides credentials for HTTP Basic Authentication.

--ssl-no-verify
    Disables SSL certificate verification, useful for testing self-signed certificates or development environments.

--duration seconds
    Runs the load test for a specified duration in seconds, instead of a fixed number of requests.

--rps rate
    Limits the rate of requests to a maximum of 'rate' requests per second.

--csv file
    Saves the detailed test results to a specified CSV formatted file.

--json file
    Saves the detailed test results to a specified JSON formatted file.

-v
    Enables verbose output, showing more details about the test execution and results.

DESCRIPTION

The loadtest command is a powerful, open-source utility designed to simulate concurrent user traffic against web applications and APIs. Developed as a Python package, it helps developers and QA engineers assess the performance, stability, and scalability of their servers under various load conditions. It measures response times, throughput, and error rates, providing crucial insights into how a system behaves when subjected to a high volume of requests. Unlike simpler tools, loadtest offers options for custom headers, POST data, HTTP methods, SSL verification control, and detailed output formats like CSV or JSON, making it suitable for a wide range of testing scenarios from basic URL performance checks to complex API endpoint validations.

CAVEATS

The loadtest command is provided by a Python package and is not a standard, pre-installed utility on most Linux distributions. It needs to be installed separately, typically via pip (e.g., pip install loadtest). Its functionality is primarily focused on HTTP/HTTPS load testing for web services.

EXAMPLE USAGE

loadtest can be used for various scenarios.

Basic GET request with concurrency:
loadtest -n 1000 -c 100 http://example.com/api/status

POST request with JSON data from file:
loadtest -n 500 -c 50 -T application/json -p data.json https://api.example.com/create

Test for a specific duration with rate limit:
loadtest --duration 60 --rps 200 http://example.com/homepage

HISTORY

The loadtest utility originates from the Python ecosystem, initially developed as a convenient command-line tool for quickly running load tests on web applications and APIs. It leverages Python's capabilities for network requests and data processing, making it accessible and extensible for developers. Its development has focused on providing a balance between ease of use for basic testing and robust options for more complex scenarios, serving as a popular choice for performance validation in agile development environments.

SEE ALSO

ab(1), wrk(1), siege(1), curl(1)

Copied to clipboard