istio 请求超时
1.路由请求到reviews 的v2 版本
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: reviews
spec:
hosts:
- reviews
http:
- route:
- destination:
host: reviews
subset: v2
[root@k8s-master01 networking]# kubectl apply -f virtual-service-reviews-v2.yaml
virtualservice.networking.istio.io/reviews unchanged
路由请求到ratings服务添加2秒的延迟。
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: ratings
spec:
hosts:
- ratings
http:
- fault:
delay:
percentage:
value: 100.0
fixedDelay: 2s
route:
- destination:
host: ratings
subset: v1
查看结果访问时间为2秒
现在针对调用的reviews服务添加0.5秒的延迟
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: reviews
spec:
hosts:
- reviews
http:
- route:
- destination:
host: reviews
subset: v2
timeout: 0.5s
[root@k8s-master01 networking]# kubectl apply -f virtual-service-reviews-v2.yaml -n istio
virtualservice.networking.istio.io/reviews configured
现在应该看到页面大约1秒后返回,并且reviews不可用。
即使超时配置为0.5秒,相应也需要1秒,这是因为productpage服务中有一个硬编码的重试,所以它在返回之前会两次调用计时的reviews服务。
posted on 2023-05-19 10:55 FLOWERS_WAN 阅读(37) 评论(0) 编辑 收藏 举报