mirror of https://github.com/istio/istio.io.git
Copy edit for Setting Request Timeouts. (#1730)
Signed-off-by: Stephen Gilson <gilsonsm@google.com>
This commit is contained in:
parent
6e97d79a2d
commit
a2836ab2b7
|
@ -27,12 +27,12 @@ This task shows you how to setup request timeouts in Envoy using Istio.
|
||||||
## Request timeouts
|
## Request timeouts
|
||||||
|
|
||||||
A timeout for http requests can be specified using the *httpReqTimeout* field of a routing rule.
|
A timeout for http requests can be specified using the *httpReqTimeout* field of a routing rule.
|
||||||
By default, the timeout is 15 seconds, but in this task we'll override the `reviews` service
|
By default, the timeout is 15 seconds, but in this task you override the `reviews` service
|
||||||
timeout to 1 second.
|
timeout to 1 second.
|
||||||
To see its effect, however, we'll also introduce an artificial 2 second delay in calls
|
To see its effect, however, you also introduce an artificial 2 second delay in calls
|
||||||
to the `ratings` service.
|
to the `ratings` service.
|
||||||
|
|
||||||
1. Route requests to v2 of the `reviews` service, i.e., a version that calls the `ratings` service
|
1. Route requests to v2 of the `reviews` service, i.e., a version that calls the `ratings` service:
|
||||||
|
|
||||||
{{< text bash >}}
|
{{< text bash >}}
|
||||||
$ cat <<EOF | istioctl replace -f -
|
$ cat <<EOF | istioctl replace -f -
|
||||||
|
@ -74,12 +74,12 @@ to the `ratings` service.
|
||||||
EOF
|
EOF
|
||||||
{{< /text >}}
|
{{< /text >}}
|
||||||
|
|
||||||
1. Open the Bookinfo URL (http://$GATEWAY_URL/productpage) in your browser
|
1. Open the Bookinfo URL `http://$GATEWAY_URL/productpage` in your browser.
|
||||||
|
|
||||||
You should see the Bookinfo application working normally (with ratings stars displayed),
|
You should see the Bookinfo application working normally (with ratings stars displayed),
|
||||||
but there is a 2 second delay whenever you refresh the page.
|
but there is a 2 second delay whenever you refresh the page.
|
||||||
|
|
||||||
1. Now add a 1 second request timeout for calls to the `reviews` service
|
1. Now add a 1 second request timeout for calls to the `reviews` service:
|
||||||
|
|
||||||
{{< text bash >}}
|
{{< text bash >}}
|
||||||
$ cat <<EOF | istioctl replace -f -
|
$ cat <<EOF | istioctl replace -f -
|
||||||
|
@ -99,44 +99,42 @@ to the `ratings` service.
|
||||||
EOF
|
EOF
|
||||||
{{< /text >}}
|
{{< /text >}}
|
||||||
|
|
||||||
1. Refresh the Bookinfo web page
|
1. Refresh the Bookinfo web page.
|
||||||
|
|
||||||
You should now see that it returns in 1 second (instead of 2), but the reviews are unavailable.
|
You should now see that it returns in 1 second, instead of 2, but the reviews are unavailable.
|
||||||
|
|
||||||
## Understanding what happened
|
## Understanding what happened
|
||||||
|
|
||||||
In this task, you used Istio to set the request timeout for calls to the `reviews`
|
In this task, you used Istio to set the request timeout for calls to the `reviews`
|
||||||
microservice to 1 second (instead of the default 15 seconds).
|
microservice to 1 second instead of the default of 15 seconds.
|
||||||
Since the `reviews` service subsequently calls the `ratings` service when handling requests,
|
Since the `reviews` service subsequently calls the `ratings` service when handling requests,
|
||||||
you used Istio to inject a 2 second delay in calls to `ratings`, so that you would cause the
|
you used Istio to inject a 2 second delay in calls to `ratings` to cause the
|
||||||
`reviews` service to take longer than 1 second to complete and consequently you could see the
|
`reviews` service to take longer than 1 second to complete and consequently you could see the timeout in action.
|
||||||
timeout in action.
|
|
||||||
|
|
||||||
You observed that the Bookinfo productpage (which calls the `reviews` service to populate the page),
|
You observed that instead of displaying reviews, the Bookinfo productpage (which calls the `reviews` service to populate the page) displayed
|
||||||
instead of displaying reviews, displayed
|
|
||||||
the message: Sorry, product reviews are currently unavailable for this book.
|
the message: Sorry, product reviews are currently unavailable for this book.
|
||||||
This was the result of it receiving the timeout error from the `reviews` service.
|
This was the result of it receiving the timeout error from the `reviews` service.
|
||||||
|
|
||||||
If you check out the [fault injection task](/docs/tasks/traffic-management/fault-injection/), you'll find out that the `productpage`
|
If you examine the [fault injection task](/docs/tasks/traffic-management/fault-injection/), you'll find out that the `productpage`
|
||||||
microservice also has its own application-level timeout (3 seconds) for calls to the `reviews` microservice.
|
microservice also has its own application-level timeout (3 seconds) for calls to the `reviews` microservice.
|
||||||
Notice that in this task we used an Istio route rule to set the timeout to 1 second.
|
Notice that in this task we used an Istio route rule to set the timeout to 1 second.
|
||||||
Had you instead set the timeout to something greater than 3 seconds (e.g., 4 seconds) the timeout
|
Had you instead set the timeout to something greater than 3 seconds (such as 4 seconds) the timeout
|
||||||
would have had no effect since the more restrictive of the two will take precedence.
|
would have had no effect since the more restrictive of the two takes precedence.
|
||||||
More details can be found [here](/docs/concepts/traffic-management/#failure-handling-faq).
|
More details can be found [here](/docs/concepts/traffic-management/#failure-handling-faq).
|
||||||
|
|
||||||
One more thing to note about timeouts in Istio is that in addition to overriding them in route rules,
|
One more thing to note about timeouts in Istio is that in addition to overriding them in route rules,
|
||||||
as you did in this task, they can also be overridden on a per-request basis if the application adds
|
as you did in this task, they can also be overridden on a per-request basis if the application adds
|
||||||
an "x-envoy-upstream-rq-timeout-ms" header on outbound requests. In the header
|
an `x-envoy-upstream-rq-timeout-ms` header on outbound requests. In the header,
|
||||||
the timeout is specified in millisecond (instead of second) units.
|
the timeout is specified in milliseconds instead of seconds.
|
||||||
|
|
||||||
## Cleanup
|
## Cleanup
|
||||||
|
|
||||||
* Remove the application routing rules.
|
* Remove the application routing rules:
|
||||||
|
|
||||||
{{< text bash >}}
|
{{< text bash >}}
|
||||||
$ istioctl delete -f @samples/bookinfo/routing/route-rule-all-v1.yaml@
|
$ istioctl delete -f @samples/bookinfo/routing/route-rule-all-v1.yaml@
|
||||||
{{< /text >}}
|
{{< /text >}}
|
||||||
|
|
||||||
* If you are not planning to explore any follow-on tasks, refer to the
|
* If you are not planning to explore any follow-on tasks, see the
|
||||||
[Bookinfo cleanup](/docs/examples/bookinfo/#cleanup) instructions
|
[Bookinfo cleanup](/docs/examples/bookinfo/#cleanup) instructions
|
||||||
to shutdown the application.
|
to shutdown the application.
|
||||||
|
|
Loading…
Reference in New Issue