This document describes manual test procedure for PR projectcontour/contour#4772
The test is executed by using k6. Additionally, it uses InfluxDB to record the performance test results and Grafana to visualize them.
Spin up influxdb and grafana using docker-compose
:
$ git clone https://github.com/grafana/k6
$ cd k6
$ docker-compose up influxdb grafana
Add new dashboard to Grafana
- Navigate to http://localhost:3000/.
- Click "Dashboards" icon in left panel, select
+ import
. - Copy content of
slowstart-grafana-panel.json
intoImport via panel json
text box and clickLoad
. - Click
Import
.
Deploy echoserver
test application:
$ kubectl apply -f https://gist.githubusercontent.com/tsaarni/a22e3d69bf6c31ff0597e9f78454868a/raw/slowstart.yaml
The manifest (attached in this gist) deploys echoserver with 5 replicas. Each instance will respond to any HTTP request with a JSON document that looks like following:
$ http http://echoserver.127-0-0-101.nip.io/
HTTP/1.1 200 OK
content-encoding: gzip
content-type: application/json
...
{
...
"host": "echoserver.127-0-0-101.nip.io",
"ingress": "",
"method": "GET",
"namespace": "default",
"path": "/",
"pod": "echoserver-8679774579-q2bxm",
...
}
Note that the response document contains the name of the pod that processed the request.
Create test script for k6
:
$ cat > slowstart.js <<EOF
import http from 'k6/http';
import exec from 'k6/execution';
export default function () {
const res = http.get('http://echoserver.127-0-0-101.nip.io');
if (res.status === 200) {
exec.vu.tags['pod'] = res.json()['pod'];
}
};
EOF
The script will send a request to echoserver and for every successful request, it will take the pod name and associate that as a tag to the test event recorded in InfluxDB. This way, we know which pod/replica responded to the request and we can visualize that in Grafana dashboard.
Start k6 with the test script:
$ docker run --rm -it --network host -e K6_OUT=influxdb=http://localhost:8086/k6 -v $PWD:/input:ro grafana/k6:latest run --vus 5 --duration 1h /input/slowstart.js
Observe that data about the traffic starts to cumulate in real-time on Grafana dashboard. The dashboard is updated automatically every 10 seconds but it can be manually refreshed by cliking the refresh button on right upper corner.
Kill one of the pods by runnign following on worker:
$ ps -ef|grep echoserver
65532 3741902 3741816 10 20:56 ? 00:01:47 /echoserver
65532 3741910 3741792 10 20:56 ? 00:01:47 /echoserver
65532 3742037 3741954 10 20:56 ? 00:01:47 /echoserver
65532 3742229 3742092 10 20:56 ? 00:01:47 /echoserver
65532 3742236 3742137 10 20:56 ? 00:01:47 /echoserver
tsaarni 3746917 9433 0 21:13 pts/1 00:00:00 grep --color echoserver
$ sudo kill 3741902
Observe in Grafana dashboard that one of the pods entered slow start mode for 10 seconds.
In the following screenshot an echoserver process in pod represented by green color was killed. The number of requests goes down to 0 and increases gradually back to original number within slow start window which was configured to 10 seconds.