Circuit breaker

The circuit breaker is an integral pattern for making microservices resilient by limiting failures, spiked latency, and other network anomalies that might disrupt a service's workflow. This capability is configured at the application layer. We should enable circuit breaker rules and then intentionally break the rules to test the resiliency of an application. The most popular tasks that enable circuit breaking are for connections, requests, and outlier detection.

Policies for circuit breaking can be defined as  DestinationRule in the YAML configuration file for a designated service. A circuit breaker rule is defined using destination rules, which are a set of policies that are requested after a VirtualService routing is defined and deployed. The DestinationRule policy execution should be a restrictive task, and only service owners should prescribe what the load balancer, circuit breaker, and TLS settings should be.

A circuit breaker helps an application to fail fast and it prevents the application from stalling if it is waiting for an upstream service response. 

We can set a limit of 100 connections for the reviews service's v1 subset through the following rule:

apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: reviews
spec:
host: reviews
subsets:
- name: v1
labels:
version: v1
trafficPolicy:
connectionPool:
tcp:
maxConnections: 100

When the v1 subset is used in a virtual service, the circuit breaker will trip when the number of connections exceeds 100. This can happen if the reviews:v1 service is slow and unable to handle a large number of concurrent requests. After the circuit breaker trips, reviews:v1 will not receive any requests until the congestion clears.   

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.44.108