istio-0.8断路器配置

断路器

让我们设置一个场景来演示Istio的断路功能。我们应该httpbin从上一节开始运行服务。

  1. 创建目标规则以在调用httpbin服务时指定断路设置:

    cat <<EOF | istioctl create -f -
    apiVersion: networking.istio.io/v1alpha3
    kind: DestinationRule
    metadata:
      name: httpbin
    spec:
      host: httpbin
      trafficPolicy:
        connectionPool:
          tcp:
            maxConnections: 1
          http:
            http1MaxPendingRequests: 1
            maxRequestsPerConnection: 1
        outlierDetection:
          http:
            consecutiveErrors: 1
            interval: 1s
            baseEjectionTime: 3m
            maxEjectionPercent: 100
    EOF
    
  2. 确认我们的目标规则已正确创建:

    $ istioctl get destinationrule httpbin -o yaml
    apiVersion: networking.istio.io/v1alpha3
    kind: DestinationRule
    metadata:
      name: httpbin
      ...
    spec:
      host: httpbin
      trafficPolicy:
        connectionPool:
          http:
            http1MaxPendingRequests: 1
            maxRequestsPerConnection: 1
          tcp:
            maxConnections: 1
        outlierDetection:
          http:
            baseEjectionTime: 180.000s
            consecutiveErrors: 1
            interval: 1.000s
            maxEjectionPercent: 100
    

设置我们的客户

现在我们已经设置了调用httpbin服务的规则,让我们创建一个客户端,我们可以使用它来向我们的服务发送流量,看看我们是否可以解决断路策略。我们将使用一个名为fortio的简单负载测试客户端。使用此客户端,我们可以控制传出HTTP调用的连接数,并发数和延迟。在这一步中,我们将设置一个注入了istio sidecar代理的客户端,以便我们的网络交互由Istio管理:

$ kubectl apply -f <(istioctl kube-inject -f @samples/httpbin/sample-client/fortio-deploy.yaml@)

现在我们应该能够登录到该客户端pod并使用简单的fortio工具进行调用httpbin。我们将传入-curl以表明我们只想打一个电话:

$ FORTIO_POD=$(kubectl get pod | grep fortio | awk '{ print $1 }')
$ kubectl exec -it $FORTIO_POD  -c fortio /usr/local/bin/fortio -- load -curl  http://httpbin:8000/get
HTTP/1.1 200 OK
server: envoy
date: Tue, 16 Jan 2018 23:47:00 GMT
content-type: application/json
access-control-allow-origin: *
access-control-allow-credentials: true
content-length: 445
x-envoy-upstream-service-time: 36

{
  "args": {},
  "headers": {
    "Content-Length": "0",
    "Host": "httpbin:8000",
    "User-Agent": "istio/fortio-0.6.2",
    "X-B3-Sampled": "1",
    "X-B3-Spanid": "824fbd828d809bf4",
    "X-B3-Traceid": "824fbd828d809bf4",
    "X-Ot-Span-Context": "824fbd828d809bf4;824fbd828d809bf4;0000000000000000",
    "X-Request-Id": "1ad2de20-806e-9622-949a-bd1d9735a3f4"
  },
  "origin": "127.0.0.1",
  "url": "http://httpbin:8000/get"
}

您可以看到请求成功!现在,让我们打破一些东西吧。

跳闸断路器

在电路中断设置中,我们指定maxConnections: 1http1MaxPendingRequests: 1。这应该意味着如果我们超过一个连接并同时请求,我们应该看到istio-proxy为进一步的请求/连接打开电路。让我们尝试两个并发连接(-c 2)并发送20个请求(-n 20

$ kubectl exec -it $FORTIO_POD  -c fortio /usr/local/bin/fortio -- load -c 2 -qps 0 -n 20 -loglevel Warning http://httpbin:8000/get
Fortio 0.6.2 running at 0 queries per second, 2->2 procs, for 5s: http://httpbin:8000/get
Starting at max qps with 2 thread(s) [gomax 2] for exactly 20 calls (10 per thread + 0)
23:51:10 W http.go:617> Parsed non ok code 503 (HTTP/1.1 503)
Ended after 106.474079ms : 20 calls. qps=187.84
Aggregated Function Time : count 20 avg 0.010215375 +/- 0.003604 min 0.005172024 max 0.019434859 sum 0.204307492
# range, mid point, percentile, count
>= 0.00517202 <= 0.006 , 0.00558601 , 5.00, 1
> 0.006 <= 0.007 , 0.0065 , 20.00, 3
> 0.007 <= 0.008 , 0.0075 , 30.00, 2
> 0.008 <= 0.009 , 0.0085 , 40.00, 2
> 0.009 <= 0.01 , 0.0095 , 60.00, 4
> 0.01 <= 0.011 , 0.0105 , 70.00, 2
> 0.011 <= 0.012 , 0.0115 , 75.00, 1
> 0.012 <= 0.014 , 0.013 , 90.00, 3
> 0.016 <= 0.018 , 0.017 , 95.00, 1
> 0.018 <= 0.0194349 , 0.0187174 , 100.00, 1
# target 50% 0.0095
# target 75% 0.012
# target 99% 0.0191479
# target 99.9% 0.0194062
Code 200 : 19 (95.0 %)
Code 503 : 1 (5.0 %)
Response Header Sizes : count 20 avg 218.85 +/- 50.21 min 0 max 231 sum 4377
Response Body/Total Sizes : count 20 avg 652.45 +/- 99.9 min 217 max 676 sum 13049
All done 20 calls (plus 0 warmup) 10.215 ms avg, 187.8 qps

我们看到几乎所有请求都通过了!

Code 200 : 19 (95.0 %)
Code 503 : 1 (5.0 %)

istio-proxy确实允许一些余地。让我们将并发连接的数量最多为3:

$ kubectl exec -it $FORTIO_POD  -c fortio /usr/local/bin/fortio -- load -c 3 -qps 0 -n 20 -loglevel Warning http://httpbin:8000/get
Fortio 0.6.2 running at 0 queries per second, 2->2 procs, for 5s: http://httpbin:8000/get
Starting at max qps with 3 thread(s) [gomax 2] for exactly 30 calls (10 per thread + 0)
23:51:51 W http.go:617> Parsed non ok code 503 (HTTP/1.1 503)
23:51:51 W http.go:617> Parsed non ok code 503 (HTTP/1.1 503)
23:51:51 W http.go:617> Parsed non ok code 503 (HTTP/1.1 503)
23:51:51 W http.go:617> Parsed non ok code 503 (HTTP/1.1 503)
23:51:51 W http.go:617> Parsed non ok code 503 (HTTP/1.1 503)
23:51:51 W http.go:617> Parsed non ok code 503 (HTTP/1.1 503)
23:51:51 W http.go:617> Parsed non ok code 503 (HTTP/1.1 503)
23:51:51 W http.go:617> Parsed non ok code 503 (HTTP/1.1 503)
23:51:51 W http.go:617> Parsed non ok code 503 (HTTP/1.1 503)
23:51:51 W http.go:617> Parsed non ok code 503 (HTTP/1.1 503)
23:51:51 W http.go:617> Parsed non ok code 503 (HTTP/1.1 503)
Ended after 71.05365ms : 30 calls. qps=422.22
Aggregated Function Time : count 30 avg 0.0053360199 +/- 0.004219 min 0.000487853 max 0.018906468 sum 0.160080597
# range, mid point, percentile, count
>= 0.000487853 <= 0.001 , 0.000743926 , 10.00, 3
> 0.001 <= 0.002 , 0.0015 , 30.00, 6
> 0.002 <= 0.003 , 0.0025 , 33.33, 1
> 0.003 <= 0.004 , 0.0035 , 40.00, 2
> 0.004 <= 0.005 , 0.0045 , 46.67, 2
> 0.005 <= 0.006 , 0.0055 , 60.00, 4
> 0.006 <= 0.007 , 0.0065 , 73.33, 4
> 0.007 <= 0.008 , 0.0075 , 80.00, 2
> 0.008 <= 0.009 , 0.0085 , 86.67, 2
> 0.009 <= 0.01 , 0.0095 , 93.33, 2
> 0.014 <= 0.016 , 0.015 , 96.67, 1
> 0.018 <= 0.0189065 , 0.0184532 , 100.00, 1
# target 50% 0.00525
# target 75% 0.00725
# target 99% 0.0186345
# target 99.9% 0.0188793
Code 200 : 19 (63.3 %)
Code 503 : 11 (36.7 %)
Response Header Sizes : count 30 avg 145.73333 +/- 110.9 min 0 max 231 sum 4372
Response Body/Total Sizes : count 30 avg 507.13333 +/- 220.8 min 217 max 676 sum 15214
All done 30 calls (plus 0 warmup) 5.336 ms avg, 422.2 qps

现在我们开始看到我们期望的断路行为。

Code 200 : 19 (63.3 %)
Code 503 : 11 (36.7 %)

只有63.3%的请求通过,其余的请求被电路中断。我们可以查询istio-proxy统计信息以查看更多信息:

$ kubectl exec -it $FORTIO_POD  -c istio-proxy  -- sh -c 'curl localhost:15000/stats' | grep httpbin | grep pending
cluster.out.httpbin.springistio.svc.cluster.local|http|version=v1.upstream_rq_pending_active: 0
cluster.out.httpbin.springistio.svc.cluster.local|http|version=v1.upstream_rq_pending_failure_eject: 0
cluster.out.httpbin.springistio.svc.cluster.local|http|version=v1.upstream_rq_pending_overflow: 12
cluster.out.httpbin.springistio.svc.cluster.local|http|version=v1.upstream_rq_pending_total: 39

我们看到12upstream_rq_pending_overflow值意味着12到目前为止已经标记了断路的电话。

 

文档:https://istio.io/docs/tasks/traffic-management/circuit-breaking/

转载于:https://my.oschina.net/xiaominmin/blog/1858660

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: SNMPB-0.8是一个基于SNMP协议的网络管理工具,用于监控和管理网络设备。该工具具有用户友好的界面和各种实用功能,可以帮助管理员监测网络中的设备和应用程序,发现并解决网络问题。 SNMPB-0.8的下载方式有很多种,其中最常见的是从官方网站下载。用户可以通过浏览器访问SNMPB-0.8的官方网站,点击“下载”按钮进入下载页面,选择适合自己操作系统的版本进行下载。 另外,也可以在第三方软件下载网站上下载SNMPB-0.8。用户可以在下载网站中搜索相应关键词,找到SNMPB-0.8的下载链接进行下载。注意,要从可靠的下载网站上下载,以避免下载到病毒或恶意软件。 总之,下载SNMPB-0.8的方式可以有多种,用户可以根据自己的需求和偏好选择最适合的下载方式。下载完成后,用户需要根据说明进行安装和配置,方可使用该工具进行网络管理。 ### 回答2: SNMPB-0.8是一个网络管理工具,用于监测和管理计算机网络中的设备。它使用SNMP(Simple Network Management Protocol)协议来收集设备的信息,并将其呈现给网络管理员。 要下载SNMPB-0.8,可以在网上搜索SNMPB-0.8下载链接,然后从可信赖的网站下载该软件。 安装完SNMPB-0.8后,需要配置它以监测和管理网络设备。首先,需要添加设备到SNMPB-0.8中,为每个设备配置唯一的IP地址和SNMP community string(SNMP社区字符串)以允许SNMPB-0.8访问该设备的信息。然后,使用SNMPB-0.8提供的工具来查询和显示设备信息以了解设备的状态和性能。 SNMPB-0.8被广泛应用于大型企业和机构的网络管理中,它能够帮助管理员快速识别和解决网络中的问题,保持网络的稳定和安全。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值