In this chapter we will configure circuit breaking using Istio. Circuit breaking allows developers to write applications that limit the impact of failures, latency spikes, and other undesirable effects of network peculiarities. This task will show how to configure circuit breaking for connections, requests, and outlier detection.
Before we can configure circuit breaking, please try to access the product page app from within Meshery to ensure all the calls are making it through without errors as we did in Observability chapter (see screenshot).
Now that we have the needed services in place, it is time to configure circuit breaking using a destination rule.
Using Meshery, navigate to the Istio management page:
default in the Namespace field.Apply Custom Configuration card and paste the configuration below.Manual step for can be found here
This will update the existing destination rule definition for product page service to break the circuit if there are more than one connection and more than one pending request.
In a few, we should be able to verify the destination rule by using the command below:
kubectl get destinationrule productpage -o yaml
Config:
1apiVersion: networking.istio.io/v1alpha32kind: DestinationRule3metadata:4 name: productpage5spec:6 host: productpage7 subsets:8 - /obserlabels:9 version: v110 name: v111 trafficPolicy:12 connectionPool:13 http:14 http1MaxPendingRequests: 115 maxRequestsPerConnection: 116 tcp:17 maxConnections: 118 outlierDetection:19 baseEjectionTime: 3m20 consecutiveErrors: 121 interval: 1s22 maxEjectionPercent: 10023 tls:24 mode: ISTIO_MUTUAL
In the circuit-breaker settings, we specified maxRequestsPerConnection: 1 and http1MaxPendingRequests:
Let us now use Meshery to make several calls to product page app by changing the number of concurrent connections to 5 from within Meshery's Performance page.
Once you have updated the fields, you now click on Run Test.
This will run the load test and show the results in a chart. ( see screenshot ).
You should only see a percentage of the requests succeed and the rest trapped by the configured circuit breaker.
1kubectl apply -f - <<EOF2apiVersion: networking.istio.io/v1alpha33kind: DestinationRule4metadata:5 name: productpage6spec:7 host: productpage8 subsets:9 - labels:10 version: v111 name: v112 trafficPolicy:13 tls:14 mode: ISTIO_MUTUAL15 connectionPool:16 tcp:17 maxConnections: 118 http:19 http1MaxPendingRequests: 120 maxRequestsPerConnection: 121 outlierDetection:22 consecutiveErrors: 123 interval: 1s24 baseEjectionTime: 3m25 maxEjectionPercent: 10026EOF