Request Timeout Override

Request Timeout Override

In this tutorial, we are going to discuss about how to override the hard coded request timeout within the microservices using virtual service. In the earlier tutorial, we discussed about how to artificially inject a delay into the microservices using the fault and fixed delay.

So within the product page we have the timeout as 3 seconds and for the reviews. We have the timeout as 10 seconds for version 2 subset and 2.5 seconds timeout for other subset.

Let’s get into the virtual services and check the current status. If I get into the Kiali web UI Istio configuration and get into the ratings virtual service.

Request Timeout Override

Now let me get into the reviews virtual service.

Request Timeout Override

Here reviews virtual service it is having the destination as version 2. So automatically it is going to have the timeout as 10 seconds. Now Let me go ahead and make a sample request and see how this particular application going to behave.

Network Traffic Shifting 1

So it’s going to have a time delay of two seconds from the ratings. And accordingly, the response from the details page will also get delayed by 2 seconds.

Inject timeout

Now I’m going to inject a timeout of 0.5 seconds for version 2. If I change this particular timeout as 0.5 seconds what will happen?

The ratings microservices will have a delay of 2 seconds and reviews version 2 subset will give the response back within 0.5 seconds saying it did not get the response back. And I will not be having any ratings within the page.

So Let me go ahead and update the virtual service or directly I can go ahead and paste the yaml file within the console.

root@cluster-node:~/istio-1.10.0# kubectl apply -f - <<EOF
kind: VirtualService
  name: reviews
  - reviews
  - route:
    - destination:
       host: reviews
       subset: v2
    timeout: 0.5s

So I’m going to update the reviews virtual service where I have hard coded the time out as 0.5 seconds for the subset version 2 that is configured. Let me go ahead and verify that within the kiali console.

Request Timeout Override2

And get into the reviews and within the yaml file I do have timeout as 0.5 seconds. So what should happen? The reviews microservices will timeout in 0.5 seconds and it will not wait for the ratings because it is going to delay for 2 seconds and it will give the response back without the ratings.

Let me go ahead and access the page.

Request Timeout Bottleneck 6

Yes. So it timed out in 0.5 seconds.

So we discussed about how to inject the timeout using the virtual services as a part of reviews within the yaml file. We added the timeout for this particular destination 0.5 seconds.

Again this will be used for testing purpose where It’s going to give the timeout in this particular duration, in case if I get the response back within this particular duration, that is 0.5 seconds I may get the output.

Change timeout from Kiali Web UI

Let me change this to say 2.5 seconds.

Request Timeout Override3

Now, let me go ahead and access the web UI.

Network Traffic Shifting 1

Yes I got the response now because the rating was delaying for 2 seconds. So by this way, I can modify the values within the YAML file using the kiali console and try out various scenarios and the combinations using fixed delay and the timeout and how the behavior is changing within the microservices.

So this proves setting the right time out for the microservices very very important within the microservices architecture within the cloud native applications using the micro service architecture.


So in a quick summary we discussed about how to make use of the time out and fixed delay within the virtual services and try out different combinations and discussed the importance of timeout setting within the microservices.

Request Timeout Override
Scroll to top