Vegeta
Vegeta is a versatile HTTP load testing tool built out of a need to drill HTTP services with a constant request rate. It can be used both as a command line utility and a library.
Github : https://github.com/tsenart/vegeta

Install
Pre-compiled executables
Get them here.
Homebrew on Mac OS X
You can install Vegeta using the Homebrew package manager on Mac OS X:
Source
You need go installed and GOBIN in your PATH. Once that is done, run the command:
Versioning
Both the library and the CLI are versioned with SemVer v2.0.0.
After v8.0.0, the two components are versioned separately to better isolate breaking changes to each.
CLI releases are tagged with cli/vMAJOR.MINOR.PATCH and published on the Github releases page. As for the library, new versions are tagged with both lib/vMAJOR.MINOR.PATCH and vMAJOR.MINOR.PATCH. The latter tag is required for compatibility with go mod.
Contributing
See CONTRIBUTING.md.
Usage manual
-cpus
-cpusSpecifies the number of CPUs to be used internally. It defaults to the amount of CPUs available in the system.
-profile
-profileSpecifies which profiler to enable during execution. Both cpu and heap profiles are supported. It defaults to none.
-version
-versionPrints the version and exits.
attack command
attack command-body
-bodySpecifies the file whose content will be set as the body of every request unless overridden per attack target, see -targets.
-cert
-certSpecifies the PEM encoded TLS client certificate file to be used with HTTPS requests. If -key isn't specified, it will be set to the value of this flag.
-connections
-connectionsSpecifies the maximum number of idle open connections per target host.
-duration
-durationSpecifies the amount of time to issue request to the targets. The internal concurrency structure's setup has this value as a variable. The actual run time of the test can be longer than specified due to the responses delay. Use 0 for an infinite attack.
-format
-formatSpecifies the targets format to decode.
json format
The JSON format makes integration with programs that produce targets dynamically easier. Each target is one JSON object in its own line. The method and url fields are required. If present, the body field must be base64 encoded. The generated JSON Schema defines the format in detail.
http format
The http format almost resembles the plain-text HTTP message format defined in RFC 2616 but it doesn't support in-line HTTP bodies, only references to files that are loaded and used as request bodies (as exemplified below).
Although targets in this format can be produced by other programs, it was originally meant to be used by people writing targets by hand for simple use cases.
Here are a few examples of valid targets files in the http format:
Simple targets
Targets with custom headers
Targets with custom bodies
Targets with custom bodies and headers
Add comments to the targets
Lines starting with # are ignored.
-h2c
-h2cSpecifies that HTTP2 requests are to be sent over TCP without TLS encryption.
-header
-headerSpecifies a request header to be used in all targets defined, see -targets. You can specify as many as needed by repeating the flag.
-http2
-http2Specifies whether to enable HTTP/2 requests to servers which support it.
-insecure
-insecureSpecifies whether to ignore invalid server TLS certificates.
-keepalive
-keepaliveSpecifies whether to reuse TCP connections between HTTP requests.
-key
-keySpecifies the PEM encoded TLS client certificate private key file to be used with HTTPS requests.
-laddr
-laddrSpecifies the local IP address to be used.
-lazy
-lazySpecifies whether to read the input targets lazily instead of eagerly. This allows streaming targets into the attack command and reduces memory footprint. The trade-off is one of added latency in each hit against the targets.
-max-body
-max-bodySpecifies the maximum number of bytes to capture from the body of each response. Remaining unread bytes will be fully read but discarded. Set to -1 for no limit. It knows how to intepret values like these:
"10 MB"->10MB"10240 g"->10TB"2000"->2000B"1tB"->1TB"5 peta"->5PB"28 kilobytes"->28KB"1 gigabyte"->1GB
-name
-nameSpecifies the name of the attack to be recorded in responses.
-output
-outputSpecifies the output file to which the binary results will be written to. Made to be piped to the report command input. Defaults to stdout.
-rate
-rateSpecifies the request rate per time unit to issue against the targets. The actual request rate can vary slightly due to things like garbage collection, but overall it should stay very close to the specified. If no time unit is provided, 1s is used.
-redirects
-redirectsSpecifies the max number of redirects followed on each request. The default is 10. When the value is -1, redirects are not followed but the response is marked as successful.
-resolvers
-resolversSpecifies custom DNS resolver addresses to use for name resolution instead of the ones configured by the operating system. Works only on non Windows systems.
-root-certs
-root-certsSpecifies the trusted TLS root CAs certificate files as a comma separated list. If unspecified, the default system CAs certificates will be used.
-targets
-targetsSpecifies the file from which to read targets, defaulting to stdin. See the -format section to learn about the different target formats.
-timeout
-timeoutSpecifies the timeout for each request. The default is 0 which disables timeouts.
-workers
-workersSpecifies the initial number of workers used in the attack. The actual number of workers will increase if necessary in order to sustain the requested rate.
report command
report commandreport -type=text
report -type=textThe Requests row shows:
The
totalnumber of issued requests.The real request
ratesustained during the attack.
The Duration row shows:
The
attacktime taken issuing all requests (total-wait)The
waittime waiting for the response to the last issued request (total-attack)The
totaltime taken in the attack (attack+wait)
Latency is the amount of time taken for a response to a request to be read (including the -max-body bytes from the response body).
meanis the arithmetic mean / average of the latencies of all requests in an attack.50,95,99are the 50th, 95th an 99th percentiles, respectively, of the latencies of all requests in an attack. To understand more about why these are useful, I recommend this article from @tylertreat.maxis the maximum latency of all requests in an attack.
The Bytes In and Bytes Out rows shows:
The
totalnumber of bytes sent (out) or received (in) with the request or response bodies.The
meannumber of bytes sent (out) or received (in) with the request or response bodies.
The Success ratio shows the percentage of requests whose responses didn't error and had status codes between 200 and 400 (non-inclusive).
The Status Codes row shows a histogram of status codes. 0 status codes mean a request failed to be sent.
The Error Set shows a unique set of errors returned by all issued requests. These include requests that got non-successful response status code.
report -type=json
report -type=jsonreport -type=hist
report -type=histComputes and prints a text based histogram for the given buckets. Each bucket upper bound is non-inclusive.
encode command
encode commandplot command
plot command
Usage: Generated targets
Apart from accepting a static list of targets, Vegeta can be used together with another program that generates them in a streaming fashion. Here's an example of that using the jq utility that generates targets with an incrementing id in their body.
Usage: Distributed attacks
Whenever your load test can't be conducted due to Vegeta hitting machine limits such as open files, memory, CPU or network bandwidth, it's a good idea to use Vegeta in a distributed manner.
In a hypothetical scenario where the desired attack rate is 60k requests per second, let's assume we have 3 machines with vegeta installed.
Make sure open file descriptor and process limits are set to a high number for your user on each machine using the ulimit command.
We're ready to start the attack. All we need to do is to divide the intended rate by the number of machines, and use that number on each attack. Here we'll use pdsh for orchestration.
After the previous command finishes, we can gather the result files to use on our report.
The report command accepts multiple result files. It'll read and sort them by timestamp before generating reports.
Usage: Real-time Analysis
If you are a happy user of iTerm, you can integrate vegeta with jplot using jaggr to plot a vegeta report in real-time in the comfort of you terminal:

Usage (Library)
The library versioning follows SemVer v2.0.0. Since lib/v9.0.0, the library and cli are versioned separately to better isolate breaking changes to each component.
See Versioning for more details on git tag naming schemes and compatibility with go mod.
Limitations
There will be an upper bound of the supported rate which varies on the machine being used. You could be CPU bound (unlikely), memory bound (more likely) or have system resource limits being reached which ought to be tuned for the process execution. The important limits for us are file descriptors and processes. On a UNIX system you can get and set the current soft-limit values for a user.
Just pass a new number as the argument to change it.
License
See LICENSE.
Donate
If you use and love Vegeta, please consider sending some Satoshi to 1MDmKC51ve7Upxt75KoNM6x1qdXHFK6iW2. In case you want to be mentioned as a sponsor, let me know!

Last updated
Was this helpful?