7. Failing and Recovering Quickly with the Circuit Breaker Flashcards

1
Q

What does the Circuit Breaker policy allow us to do?

A

It allows us to monitor requests sent to a remote service and stop requests before they are sent if the remote service is struggling or has been returning errors.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How does the Circut Breaker policy help the local apps vs the remote apps?

A

It helps the local apps by preventing a build-up of requests and helps the remote service by reducing the number of requests it receives.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

In what application structure is the Circuit Breaker policy most popular.

A

It is the most popular in microservices architecture.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Is the Circuit Breaker a proactive or a reactive policy?

A

It’s a reactive policy.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What can be said about the Circuit Breaker policy with regards to stability?

A

It helps stabilise local and remote apps by cutting the connection between them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What can be said about the concepts of “open” and “closed” for a Circut Breaker?

A

We can think of them as an electrical circuit.

If there is an opening, no electricity (or in our case, no requests) will flow. But if the circuit is closed, electricity (requests) will flow.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the two implementations of the Circuit Breaker policy that Polly offers?

A
  1. The Original one, introduced in Polly v4.0

2. The Advanced one, introduced in Polly v4.2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How does the Original Circuit Breaker work?

A

It sums the number of consecutive failures and if that number reaches some threshold, the circuit is opened for a specified duration, thus preventing any further requests from being sent by the given policy.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What can be said about the throughput needed to open the circuit for the Original Circuit Breaker?

A

No minimum throughput is needed. So, if we reach the specified threshold for errors, it doesn’t matter if we reached it in a second, a minute, or several hours.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How does the Advanced Circuit Breaker work?

A

It monitors the number of failures as a percentage of the total number of requests over a rolling time window. And if there are more failures than a specified threshold, the circuit breaks for a specified duration.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What can be said about the throughput needed to open the circuit for the Advanced Circuit Breaker?

A

The Advanced Circuit Breaker allows a minimum throughput threshold. This means that we can specify a time period in which the specified threshold for errors must be reached in order for the circuit to be broken.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What can be said about calling a single vs multiple endpoints using a Circuit Breaker?

A

The Circuit Breaker policy can be used to call a single remote endpoint or multiple remote endpoints.

In the first case, if the circuit breaks, you will be disconnected from just one endpoint. But in the latter case, if the circuit breaks, and and all remote services you are connecting to using that policy will be unavailable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the states that a Circuit Breaker might be in?

A
  1. Open
  2. Closed
  3. Half-open
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the half-open Circuit Breaker state?

A

It’s the state the breaker moves to after open. This can be seen as a trial state.

If the first request sent via the policy fails, the circuit is immediately set back to the open state and no requests will be sent for another period as specified in the duration of the break. But, if the first request succeeds., the circuit is closed and the request flows as normal.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What state does the Circuit Breaker policy start in, and what changes in its state does it go through when a request fails?

A

It starts in the closed state and can go through the following changes:

  1. Closed to open when a problem is detected.
  2. Open to half-open when the duration of the break is reached.
    3a. Half-open back to open if the first request at half-open fails.
    3b. Half-open to closed if the first request at half-open succeeds.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do we break the circuit for multiple remote services at the same time?

A

By using the Singleton scope while adding the Circuit Breaker policy as a dependency to our ASP.NET application. Then, we use the policy in a given set of services. When a service triggers the circuit breaker logic, the circuit is broken for all services that use it.