Overview
The order service has a timeout period of three seconds as shown below:
After fault injection is configured for the stock service, it is found that user requests to the website will be in the waiting status due to the fault. To optimize the browsing experience, a timeout period needs to be configured.
Directions
Configure a timeout period of three seconds for the order service by applying the following VirtualService
and no timeout period for the cart service.
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: order-vs
namespace: base
spec:
hosts:
- order.base.svc.cluster.local
http:
- match:
- headers:
cookie:
exact: vip=false
route:
- destination:
host: order.base.svc.cluster.local
subset: v1
timeout: 3000ms
- match:
- headers:
cookie:
exact: vip=true
route:
- destination:
host: order.base.svc.cluster.local
subset: v2
timeout: 3000ms
After the configuration, add an item to the cart, and the cart service will experience an access latency of seven seconds due to the injected fault, without a timeout. Then, click CHECKOUT to start the checkout process and call the order service, and, in addition to the access latency of seven seconds, the order service will experience a timeout period of three seconds, which means a timeout will occur if no operation is performed within three seconds after the order service is called.
The timeout occurring when the cart service calls the order service is as shown below:
After completing the timeout configuration and the fault injection test on the service, delete the VirtualService
resource associated with the stock service to disassociate the configured fault injection policy from the stock service.
Delete the VirtualService
associated with the stock service as shown below:
Was this page helpful?