Simple HTTP Load Testing with SLOs
Prerequisites: Get Iter8 CLI and Run Sample App
- Install the Iter8 CLI using one of the following methods.
-
- Using Brew
brew tap iter8-tools/iter8
brew install iter8
-
- Using precompiled binaries
Precompiled Iter8 binaries for many platforms are available here. Uncompress the iter8-X-Y.tar.gz archive for your platform, and move the iter8 binary to any folder in your PATH.
-
- Using Go 1.16+
go install github.com/iter8-tools/iter8@latest
You can now run iter8 from your gopath bin/ directory.
2. We will use httpbin as the target service. Run it in a separate terminal as follows.
docker run -p 80:80 kennethreitz/httpbin
Part 1: Basic Load Test with SLOs
Iter8 provides a predefined and highly customizable experiment chart for load testing. Similar to a Helm chart, Iter8’s experiment charts can be combined with values to create fully specified experiments that can be run by Iter8. Download the load test HTTP experiment chart as follows.
iter8 hub -e load-test-http
cd load-test-http
iter8 run --set url=http://127.0.0.1/get \
--set SLOs.error-rate=0 \
--set SLOs.latency-mean=50 \
--set SLOs.latency-p90=100 \
--set SLOs.latency-p'97\.5'=200
- Latency percentiles [25.0, 50.0, 75.0, 90.0, 95.0, 97.5, 99.0, 99.9] are collected and reported.
- The following SLOs are validated.
- error rate is 0
- mean latency is under 50 msec
- 90th percentile latency is under 100 msec
- 97.5th percentile latency is under 200 msec
iter8 assert -c completed -c nofailure -c slos
iter8 report -o html > report.html
Part 2: Load Characteristics
Iter8 makes it easy to control the load-related characteristics of the request stream that is generated by Iter8. In particular, you can specify the number of queries/duration of the load test, the number of queries sent per second and the number of parallel connections used to send requests. The following example shows how to set the total number of requests sent to 200 (numQueries), number of requests per second to 10 (qps) and the number of parallel connections to five (connections). Replace the iter8 run command used in Part 1 with the following.
iter8 run --set url=http://127.0.0.1/get \
--set SLOs.error-rate=0 \
--set SLOs.latency-mean=50 \
--set SLOs.latency-p90=100 \
--set SLOs.latency-p'97\.5'=200 \
--set numQueries=200 \
--set qps=10 \
--set connections=5
Part 3: Shape of the Requests
HTTP services with POST endpoints may accept payloads as part of requests. Iter8 makes it easy to send various types of content as payload during the load test. In the following example, Iter8 downloads a JSON object and uses the downloaded JSON as the payload in POST requests; the type of payload is set to “application/json”.
iter8 run --set url=http://127.0.0.1/post \
--set payloadURL=https://json-generator.com/ \
--set contentType="application/json" \
--set SLOs.error-rate=0 \
--set SLOs.latency-mean=50 \
--set SLOs.latency-p90=100 \
--set SLOs.latency-p'97\.5'=200
iter8 run --set url=http://127.0.0.1/post \
--set payloadURL=https://cdn.pixabay.com/photo/2021/09/08/17/58/poppy-6607526_1280.jpg \
--set contentType="image/jpeg" \
--set SLOs.error-rate=0 \
--set SLOs.latency-mean=50 \
--set SLOs.latency-p90=100 \
--set SLOs.latency-p'97\.5'=200
iter8 run --set url=http://127.0.0.1/post \
--set payloadStr="abc123" \
--set contentType="text/plain" \
--set SLOs.error-rate=0 \
--set SLOs.latency-mean=50 \
--set SLOs.latency-p90=100 \
--set SLOs.latency-p'97\.5'=200