Istio Circuit Breaker
In this tutorial, we are going to discuss the istio circuit breaker introduction. Circuit breakers help us develop resilient microservice applications where it allows the application to limit the impact of failures, latency spikes, and other undesirable effects of network peculiarities within the microservices.
It’s one of the basic patterns within the microservices architecture, where I can set the limits for the calls happening within an individual microservices within the mesh.
I can set the number of concurrent connections. How many times a call can get failed within that particular host. Once that particular limit is reached, it will trip, so further connections will not get established within that specific host.
So this is going to allow the services to fail faster than the microservices waiting for overloaded or fading microservices. And since we do have the sidecar envoy, I can put in the conditions for the circuit breaker using the pilot.
Let’s consider a small example.
Assume I do have a user accessing a microservice using the istio ingress. And let’s assume the user is making ten requests. All the ten requests will be routed to the actual microservices and that microservices internally using the database. So all ten requests will land up with the database to access the data.
So simultaneously, it’s going to access the database. Now, what’s going to happen? It will create a massive load on the database, and the user may expect undesirable behavior in terms of an increase in latency or unexpected failures.
Destination Policy
Now, as an administrator, what I can do I can create a destination policy using the istio pilot and put in a circuit breaker condition and deploy the conditions into all the sidecars.
That is envoy proxy, and the circuit breaker conditions could be like how many connections at a time. There could be a maximum number of connections allowed to a database and how many connections can be there in pending state.
Let us consider an example.
Here I will put in a circuit breaker condition as a maximum number of connections with one and pending connection as 1. I will be deploying this particular destination policy with this circuit breaker conditions into the envoy.
So when the user making ten connections, The first connection will get through, and the second connection will get into the pending state and will reject the remaining connections with the error message. And this is going to provide a faster failure so that the other services don’t need to wait for a longer time.
So this will be very useful to handle the sudden spike within the microservices in a pre-defined time. Say, for example, whenever I am having an offer opened for the application, what I can do I can allow X number of connections.
And beyond that, I can reject rather than fail the entire microservices and impact all the requests. To learn about the circuit breaker, I will use a few of the samples like http bin and fortio load creator.
We will be having a detailed discussion about these two samples in the following tutorial and do the demo for Circuit Breaker.
Summary
So in a quick summary, we discussed what circuit breaker is and its uses within the microservice architecture and how istio can help deploy the circuit breaker conditions into the proxy without making any change to the actual code.