Skip to content

Load test HTTP endpoint

Run your first performance test by load testing a Kubernetes HTTP service and visualizing the performance with an Iter8 Grafana dashboard.

Load test HTTP

Before you begin
  1. Ensure that you have a Kubernetes cluster and the kubectl and helm CLIs. If using a local cluster (for example, Kind or Minikube), we recommend providing the cluster with at least 16GB of memory.
  2. Deploy the sample HTTP service in the Kubernetes cluster.
    kubectl create deploy httpbin --image=kennethreitz/httpbin --port=80
    kubectl expose deploy httpbin --port=80
    
  3. Have Grafana available. For example, Grafana can be installed on your cluster as follows:
    kubectl create deploy grafana --image=grafana/grafana
    kubectl expose deploy grafana --port=3000
    

Install the Iter8 controller

Iter8 can be installed and configured to watch resources either in a single namespace (namespace-scoped) or in the whole cluster (cluster-scoped).

helm install --repo https://iter8-tools.github.io/iter8 --version 1.1 iter8 controller
helm install --repo https://iter8-tools.github.io/iter8 --version 1.1 iter8 controller \
--set clusterScoped=true

For additional install options, see Iter8 Installation.

Launch performance test

helm upgrade --install \
--repo https://iter8-tools.github.io/iter8 --version 1.1 httpbin-test iter8 \
--set "tasks={ready,http}" \
--set ready.deploy=httpbin \
--set ready.service=httpbin \
--set ready.timeout=60s \
--set http.url=http://httpbin.default/get
helm upgrade --install \
--repo https://iter8-tools.github.io/iter8 --version 1.1 httpbin-test iter8 \
--set "tasks={ready,http}" \
--set ready.deploy=httpbin \
--set ready.service=httpbin \
--set ready.timeout=60s \
--set http.url=http://httpbin.default/post \
--set http.payloadStr=hello
About this performance test

This performance test consists of two tasks, namely, ready and http.

The ready task checks if the httpbin deployment exists and is available, and the httpbin service exists.

The http task sends requests to the cluster-local HTTP service using the specified url, and collects Iter8's built-in HTTP load test metrics. This tasks supports both GET and POST requests, and for POST requests, a payload can be provided by using either payloadStr or payloadURL.

View results using Grafana

Inspect the metrics using Grafana. If Grafana is deployed to your cluster, port-forward requests as follows:

kubectl port-forward service/grafana 3000:3000

Open Grafana in a browser by going to http://localhost:3000 and login. The default username/password are admin/admin.

Add a JSON API data source httpbin-test with the following parameters:

  • URL: http://iter8.default:8080/httpDashboard
  • Query string: namespace=default&test=httpbin-test

Create a new dashboard by import. Paste the contents of the http Grafana dashboard into the text box and load it. Associate it with the JSON API data source defined above.

The Iter8 dashboard will look like the following:

http Iter8 dashboard

View logs

Logs are useful for debugging. To see the test logs:

kubectl logs -l iter8.tools/test=httpbin-test
Sample performance test logs
  time=2023-09-01 19:31:40 level=info msg=task 2: ready: started
  time=2023-09-01 19:31:40 level=info msg=task 2: ready: completed
  time=2023-09-01 19:31:40 level=info msg=task 3: http: started
  {"ts":1693596700.013507,"level":"info","file":"httprunner.go","line":100,"msg":"Starting http test","run":"0","url":"http://httpbin.default/get","threads":"4","qps":"8.0","warmup":"parallel","conn-reuse":""}
  {"ts":1693596712.606946,"level":"info","file":"periodic.go","line":832,"msg":"T001 ended after 12.534760214s : 25 calls. qps=1.9944537887591696"}
  {"ts":1693596712.616122,"level":"info","file":"periodic.go","line":832,"msg":"T002 ended after 12.544591006s : 25 calls. qps=1.9928907995519867"}
  {"ts":1693596712.623089,"level":"info","file":"periodic.go","line":832,"msg":"T003 ended after 12.551572714s : 25 calls. qps=1.9917822706086104"}
  {"ts":1693596712.628555,"level":"info","file":"periodic.go","line":832,"msg":"T000 ended after 12.557040548s : 25 calls. qps=1.9909149695293316"}
  {"ts":1693596712.629567,"level":"info","file":"periodic.go","line":564,"msg":"Run ended","run":"0","elapsed":"12.557657464s","calls":"100","qps":"7.963268649959411"}
  time=2023-09-01 19:31:52 level=info msg=task 3: http: completed

Cleanup

Remove the performance test and the sample app from the Kubernetes cluster.

helm delete httpbin-test
kubectl delete svc/httpbin
kubectl delete deploy/httpbin

Uninstall the Iter8 controller

helm delete iter8

For additional uninstall options, see Iter8 Uninstall.

If you installed Grafana, you can delete it as follows:

kubectl delete svc/grafana deploy/grafana

Congratulations! 🎉 You completed your first performance test with Iter8.


Some variations and extensions of this performance test
  1. The http task can be configured with load related parameters such as the number of requests, queries per second, or number of parallel connections.
  2. The http task can be configured to send various types of content as payload.