Resilient Application Design Patterns
- 50Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
- spaceFlip card
- KI knew it
- DI didn't know it
- ←Previous card
- →Next card
What does the principle “failures are given and everything will eventually fail over time” mean for distributed applications?
Applications should be designed with the expectation that hardware, networks, or software components will eventually fail.
Or swipe the card
50 cards
What does the principle “failures are given and everything will eventually fail over time” mean for distributed applications?
Applications should be designed with the expectation that hardware, networks, or software components will eventually fail.
What is the goal of designing for failure in a distributed application?
To ensure that when a component fails, the application can recover and continue serving users.
What five resilience patterns are presented for distributed applications?
Timeouts, graceful degradation, retries, exponential backoff, and circuit breakers.
What resilience practice is presented alongside the five patterns?
Chaos engineering.
What is the architecture of the example joke application?
A React application calls a .NET microservice, which proxies requests through a joke client to a third-party joke API.
What is the purpose of the React component
fetch-data.jsin the example application?It calls the
api/Jokeendpoint, parses the response as JSON, and renders the returned jokes.What data fields does the example joke object contain?
A setup, a punchline, and a source.
What can happen when the third-party joke API becomes slow or unavailable and no resilience pattern is used?
Requests wait indefinitely, additional requests accumulate, the dependency becomes more overloaded, and the .NET microservice may eventually fail.
What is the purpose of a timeout in a distributed application?
To stop waiting for a response after a defined period.
How can a timeout be configured directly in a .NET
HttpClient?Set the client's
Timeoutproperty to aTimeSpan, such as five seconds.What happens when a direct
HttpClienttimeout is exceeded?The request times out and produces a timeout exception.
What limitation does a basic
HttpClienttimeout have in the example?It provides limited control because it simply produces an exception that is not handled by the UI.
What is Polly?
A .NET resilience library used to implement policies such as timeouts, fallbacks, retries, and circuit breakers.
How does Polly provide more granular control over a timeout?
It wraps the request in an asynchronous timeout policy and passes a cancellation token to the operation.
What is graceful degradation?
Continuing to provide a useful response by using an alternative when the normal dependency or operation fails.
What is a fallback policy in Polly?
A policy that is invoked when another policy encounters an exception and returns an alternative result.
How is a fallback policy combined with another policy in the example?
The fallback policy is wrapped around the other policy in a policy wrapper.
How does the example indicate that a graceful fallback was used?
The returned joke's
sourcefield is set tofallback.What condition triggers the graceful fallback in the example?
An exception occurs within the timeout-controlled request, such as when the API takes longer than five seconds.
What is the purpose of a retry policy?
To attempt a failed request again in case the failure is temporary.
How is a retry policy configured in the example?
It handles an exception, defines a retry count, and specifies an asynchronous retry operation.
What happens when the example's retry policy exhausts its five retries?
The policy proceeds to the fallback policy and returns the fallback joke.
How do retries interact with timeouts in the example?
Each individual request has its own timeout, and the service retries after each timed-out attempt.
Why can a basic retry strategy overload a third-party service?
Many clients retry the same failing service repeatedly, potentially creating a distributed denial-of-service-like load.
What is exponential backoff?
A retry strategy that increases the waiting period after each failed attempt.
What sequence of delays illustrates exponential backoff in the example?
Two seconds, four seconds, eight seconds, and sixteen seconds.
Why is exponential backoff an improvement over immediate repeated retries?
It spreads retry traffic over time and reduces the load placed on the failing third-party API.
How is exponential backoff implemented conceptually in the example?
The wait duration is calculated using a power of two based on the retry attempt.
What problem can still occur when clients use the same exponential backoff schedule?
Retries can cluster at the same times and partially cancel out the load-spreading benefit.
What is jitter in a retry strategy?
A random variation added to retry delays to prevent retries from clustering.
How is jitter added in the example?
A random delay between zero and one thousand milliseconds is added to the retry wait time.
What is the combined benefit of exponential backoff and jitter?
Exponential backoff increases the spacing between retries, while jitter randomizes their timing to reduce synchronized load.
What is a circuit breaker pattern?
A mechanism that stops sending requests to a repeatedly failing dependency and returns an alternative response instead.
What problem does a circuit breaker solve after retries and backoff have failed?
It prevents useless continued requests and retries from reaching the broken third-party API.
What are the main states or behaviors described for the circuit breaker?
It allows requests initially, opens after repeated failures, returns a dummy or fallback response while open, and later allows requests again.
What failure threshold and break duration are used in the example circuit breaker?
Five exceptions within a minute cause the circuit to break for one minute.
What type of error does the circuit-breaker fallback handle?
A circuit breaker exception, specifically a broken-circuit exception.
How does the application respond while the circuit breaker is open?
It immediately returns a predefined circuit-breaker fallback joke without calling or retrying the third-party API.
Why must the circuit-breaker policy retain state across requests?
It must remember failures and whether the circuit is currently open.
Why are the policies initialized when the joke client is constructed rather than for every method call?
This creates the policies once and allows their state to persist across requests.
What is chaos engineering?
The practice of deliberately injecting failures or stress into systems, observing their behavior, and using the results to improve them.
What are the main goals of chaos engineering?
To improve system resilience and performance by uncovering hidden issues and exposing blind spots.
Why can chaos engineering be difficult to implement traditionally?
It may require stitching together scripts and tools, installing agents or complex libraries, and creating realistic test environments.
Why is injecting chaos directly into production challenging?
Production systems serve real users, so uncontrolled failure injection can cause unacceptable disruption.
What is the Fault Injection Simulator used for?
It is used to inject controlled failures into real systems so their resilience can be tested.
What is a chaos engineering experiment in the example?
An experiment that stops selected EC2 instances running the third-party API for one minute.
How are targets selected for the instance-stopping experiment?
The experiment selects instances using a tag identifying the API servers.
What sequence is used to run a fault-injection experiment?
Define an action and target, specify parameters and tags, create the experiment, and then run it.
What does the example demonstrate about the Fault Injection Simulator's actions?
It can perform more actions than simply stopping a server, including actions involving container instances.
What kinds of parameters can be controlled in a chaos experiment?
The target resources, the action performed, and the duration and timing of the injected fault.

Ask anything
We've read this whole study set, so questions about it get the best answers.