Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update HTTP and gRPC tutorials #65

Merged
merged 4 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions docs/getting-started/logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
```shell
INFO[2022-06-27 11:50:39] inited Helm config
INFO[2022-06-27 11:50:39] experiment logs from Kubernetes cluster indented-trace=below ...
time=2022-06-27 15:48:59 level=info msg=task 1: ready : started
time=2022-06-27 15:48:59 level=info msg=task 1: ready : completed
time=2022-06-27 15:48:59 level=info msg=task 2: ready : started
time=2022-06-27 15:48:59 level=info msg=task 2: ready : completed
time=2022-06-27 15:48:59 level=info msg=task 3: http : started
time=2022-06-27 15:49:11 level=info msg=task 3: http : completed
time=2022-06-27 15:49:11 level=info msg=task 4: assess : started
time=2022-06-27 15:49:11 level=info msg=task 4: assess : completed
time=2022-06-27 15:48:59 level=info msg=task 1: ready: started
time=2022-06-27 15:48:59 level=info msg=task 1: ready: completed
time=2022-06-27 15:48:59 level=info msg=task 2: ready: started
time=2022-06-27 15:48:59 level=info msg=task 2: ready: completed
time=2022-06-27 15:48:59 level=info msg=task 3: http: started
time=2022-06-27 15:49:11 level=info msg=task 3: http: completed
time=2022-06-27 15:49:11 level=info msg=task 4: assess: started
time=2022-06-27 15:49:11 level=info msg=task 4: assess: completed
```
39 changes: 27 additions & 12 deletions docs/getting-started/your-first-experiment.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,39 @@ Run your first [Iter8 experiment](concepts.md#iter8-experiment) by load testing
## Launch experiment
Launch the Iter8 experiment inside the Kubernetes cluster.

```shell
iter8 k launch \
--set "tasks={ready,http,assess}" \
--set ready.deploy=httpbin \
--set ready.service=httpbin \
--set ready.timeout=60s \
--set http.url=http://httpbin.default/get \
--set assess.SLOs.upper.http/latency-mean=50 \
--set assess.SLOs.upper.http/error-count=0 \
--set runner=job
```
=== "GET example"
```shell
iter8 k launch \
--set "tasks={ready,http,assess}" \
--set ready.deploy=httpbin \
--set ready.service=httpbin \
--set ready.timeout=60s \
--set http.url=http://httpbin.default/get \
--set assess.SLOs.upper.http/latency-mean=50 \
--set assess.SLOs.upper.http/error-count=0 \
--set runner=job
```

=== "POST example"
```shell
iter8 k launch \
--set "tasks={ready,http,assess}" \
--set ready.deploy=httpbin \
--set ready.service=httpbin \
--set ready.timeout=60s \
--set http.url=http://httpbin.default/post \
--set http.payloadStr=hello \
--set assess.SLOs.upper.http/latency-mean=50 \
--set assess.SLOs.upper.http/error-count=0 \
--set runner=job
```

??? note "About this experiment"
This experiment consists of three [tasks](concepts.md#iter8-experiment), namely, [ready](../user-guide/tasks/ready.md), [http](../user-guide/tasks/http.md), and [assess](../user-guide/tasks/assess.md).

The [ready](../user-guide/tasks/ready.md) task checks if the `httpbin` deployment exists and is available, and the `httpbin` service exists.

The [http](../user-guide/tasks/http.md) task sends requests to the cluster-local HTTP service whose URL is `http://httpbin.default/get`, and collects [Iter8's built-in HTTP load test metrics](../user-guide/tasks/http.md#metrics).
The [http](../user-guide/tasks/http.md) task sends requests to the cluster-local HTTP service using the specified `url`, and collects [Iter8's built-in HTTP load test metrics](../user-guide/tasks/http.md#metrics). This tasks supports both GET and POST requests, and for POST requests, a payload can be provided by using either `payloadStr` or `payloadURL`.

The [assess](../user-guide/tasks/assess.md) task verifies if the app satisfies the specified SLOs: i) the mean latency of the service does not exceed 50 msec, and ii) there are no errors (4xx or 5xx response codes) in the responses.

Expand Down
97 changes: 75 additions & 22 deletions docs/tutorials/load-test-grpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,44 +16,97 @@ Load test a Kubernetes gRPC service and validate its [service-level objectives (
1. Try [your first experiment](../getting-started/your-first-experiment.md). Understand the main [concepts](../getting-started/concepts.md) behind Iter8 experiments.
2. Deploy the sample gRPC service in the Kubernetes cluster.
```shell
kubectl create deploy hello --image=docker.io/grpc/java-example-hostname:latest --port=50051
kubectl expose deploy hello --port=50051
kubectl create deployment routeguide --image=golang --port=50051 \
-- bash -c "git clone -b v1.52.0 --depth 1 https://github.com/grpc/grpc-go; cd grpc-go/examples/route_guide; go run server/server.go"
kubectl expose deployment routeguide --port=50051
```

***

## Launch experiment

```shell
iter8 k launch \
--set "tasks={ready,grpc,assess}" \
--set ready.deploy=hello \
--set ready.service=hello \
--set ready.timeout=60s \
--set grpc.host="hello.default:50051" \
--set grpc.call="helloworld.Greeter.SayHello" \
--set grpc.protoURL="https://raw.githubusercontent.com/grpc/grpc-go/master/examples/helloworld/helloworld/helloworld.proto" \
--set assess.SLOs.upper.grpc/error-rate=0 \
--set assess.SLOs.upper.grpc/latency/mean=200 \
--set assess.SLOs.upper.grpc/latency/p'97\.5'=800 \
--set runner=job
```
=== "Unary example"
```shell
iter8 k launch \
--set "tasks={ready,grpc,assess}" \
--set ready.deploy=routeguide \
--set ready.service=routeguide \
--set ready.timeout=60s \
--set grpc.host="routeguide.default:50051" \
--set grpc.call="routeguide.RouteGuide.GetFeature" \
--set grpc.protoURL="https://raw.githubusercontent.com/grpc/grpc-go/master/examples/route_guide/routeguide/route_guide.proto" \
--set grpc.dataURL="https://raw.githubusercontent.com/iter8-tools/docs/main/samples/grpc-payload/unary.json" \
--set assess.SLOs.upper.grpc/error-rate=0 \
--set assess.SLOs.upper.grpc/latency/mean=200 \
--set assess.SLOs.upper.grpc/latency/p'97\.5'=800 \
--set runner=job
```

=== "Server streaming example"
```shell
iter8 k launch \
--set "tasks={ready,grpc,assess}" \
--set ready.deploy=routeguide \
--set ready.service=routeguide \
--set ready.timeout=60s \
--set grpc.host="routeguide.default:50051" \
--set grpc.call="routeguide.RouteGuide.ListFeatures" \
--set grpc.protoURL="https://raw.githubusercontent.com/grpc/grpc-go/master/examples/route_guide/routeguide/route_guide.proto" \
--set grpc.dataURL="https://raw.githubusercontent.com/iter8-tools/docs/main/samples/grpc-payload/server.json" \
--set assess.SLOs.upper.grpc/error-rate=0 \
--set assess.SLOs.upper.grpc/latency/mean=200 \
--set assess.SLOs.upper.grpc/latency/p'97\.5'=800 \
--set runner=job
```

=== "Client streaming example"
```shell
iter8 k launch \
--set "tasks={ready,grpc,assess}" \
--set ready.deploy=routeguide \
--set ready.service=routeguide \
--set ready.timeout=60s \
--set grpc.host="routeguide.default:50051" \
--set grpc.call="routeguide.RouteGuide.RecordRoute" \
--set grpc.protoURL="https://raw.githubusercontent.com/grpc/grpc-go/master/examples/route_guide/routeguide/route_guide.proto" \
--set grpc.dataURL="https://raw.githubusercontent.com/iter8-tools/docs/main/samples/grpc-payload/client.json" \
--set assess.SLOs.upper.grpc/error-rate=0 \
--set assess.SLOs.upper.grpc/latency/mean=200 \
--set assess.SLOs.upper.grpc/latency/p'97\.5'=800 \
--set runner=job
```

=== "Bidirectional example"
```shell
iter8 k launch \
--set "tasks={ready,grpc,assess}" \
--set ready.deploy=routeguide \
--set ready.service=routeguide \
--set ready.timeout=60s \
--set grpc.host="routeguide.default:50051" \
--set grpc.call="routeguide.RouteGuide.RouteChat" \
--set grpc.protoURL="https://raw.githubusercontent.com/grpc/grpc-go/master/examples/route_guide/routeguide/route_guide.proto" \
--set grpc.dataURL="https://raw.githubusercontent.com/iter8-tools/docs/main/samples/grpc-payload/bidirectional.json" \
--set assess.SLOs.upper.grpc/error-rate=0 \
--set assess.SLOs.upper.grpc/latency/mean=200 \
--set assess.SLOs.upper.grpc/latency/p'97\.5'=800 \
--set runner=job
```

??? note "About this experiment"
This experiment consists of three [tasks](../getting-started/concepts.md#iter8-experiment), namely, [ready](../user-guide/tasks/ready.md), [grpc](../user-guide/tasks/grpc.md), and [assess](../user-guide/tasks/assess.md).

The [ready](../user-guide/tasks/ready.md) task checks if the `hello` deployment exists and is available, and the `hello` service exists.
The [ready](../user-guide/tasks/ready.md) task checks if the `routeguide` deployment exists and is available, and the `routeguide` service exists.

The [grpc](../user-guide/tasks/grpc.md) task sends call requests to the `helloworld.Greeter.SayHello` method of the cluster-local gRPC service with host address `hello.default:50051`, and collects [Iter8's built-in gRPC load test metrics](../user-guide/tasks/grpc.md#metrics).
The [grpc](../user-guide/tasks/grpc.md) task sends call requests to the specified method of the cluster-local gRPC service with host address `routeguide.default:50051` and collects [Iter8's built-in gRPC load test metrics](../user-guide/tasks/grpc.md#metrics). This task supports all four gRPC service methods: unary, server streaming, client streaming, and bidirectional streaming, and will provide payload in the appropriate manner using `dataURL`.

The [assess](../user-guide/tasks/assess.md) task verifies if the app satisfies the specified SLOs: i) there are no errors, ii) the mean latency of the service does not exceed 50 msec, and iii) the `97.5`th percentile latency does not exceed 200 msec.

This is a [single-loop](../getting-started/concepts.md#iter8-experiment) [Kubernetes experiment](../getting-started/concepts.md#kubernetes-experiments) where all the previously mentioned tasks will run once and the experiment will finish. Hence, its [runner](../getting-started/concepts.md#runners) value is set to `job`.

??? note "Some variations and extensions of this experiment"
1. The [grpc task](../user-guide/tasks/grpc.md) can be configured with load related parameters such as the total number of requests, requests per second, or number of concurrent connections.
2. The [grpc task](../user-guide/tasks/grpc.md) can be configured to JSON or binary data as payload. You can use this task to test unary or streaming gRPC methods.
3. The [assess task](../user-guide/tasks/assess.md) can be configured with SLOs for any of [Iter8's built-in grpc load test metrics](../user-guide/tasks/grpc.md#metrics).
2. The [assess task](../user-guide/tasks/assess.md) can be configured with SLOs for any of [Iter8's built-in grpc load test metrics](../user-guide/tasks/grpc.md#metrics).

***

Expand All @@ -65,6 +118,6 @@ Assert experiment outcomes, view experiment report, view experiment logs, and cl
Remove the Iter8 experiment and the sample app from the Kubernetes cluster and the local Iter8 `charts` folder.
```shell
iter8 k delete
kubectl delete svc/hello
kubectl delete deploy/hello
kubectl delete svc/routeguide
kubectl delete deploy/routeguide
```
23 changes: 23 additions & 0 deletions samples/grpc-payload/bidirectional.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[
{
"location": {
"latitude": 407838351,
"longitude": -746143763
},
"message": "Nice"
},
{
"location": {
"latitude": 408122808,
"longitude": -743999179
},
"message": "Nice"
},
{
"location": {
"latitude": 413628156,
"longitude": -749015468
},
"message": "Nice"
}
]
14 changes: 14 additions & 0 deletions samples/grpc-payload/client.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"latitude": 407838351,
"longitude": -746143763
},
{
"latitude": 408122808,
"longitude": -743999179
},
{
"latitude": 413628156,
"longitude": -749015468
}
]
10 changes: 10 additions & 0 deletions samples/grpc-payload/server.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"lo": {
"latitude": 407838351,
"longitude": -746143763
},
"hi": {
"latitude": 417838351,
"longitude": -756143763
}
}
4 changes: 4 additions & 0 deletions samples/grpc-payload/unary.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"latitude": 407838351,
"longitude": -746143763
}