Resilient Application Design Patterns
- 52Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What does the statement “failures are given and everything will eventually fail over time” imply for distributed cloud-native application design?
52 questions
- 1
What does the statement “failures are given and everything will eventually fail over time” imply for distributed cloud-native application design?
Model answer
Applications should be designed with the expectation that hardware, networks, and software components will eventually fail. They must be able to recover and continue serving users when failures occur.
Explanation
Distributed applications depend on many components and technology stacks, any of which can fail. Resilience comes from anticipating failure modes during design rather than treating failures as unusual events.
- 2
Why can failures occur in a modern distributed application?
Model answer
A distributed application uses multiple hardware components, networks, and software stacks, and any one of them can fail over time.
Explanation
The more components an application depends on, the more possible points of failure it has. Resilient design accounts for failures across the entire system.
- 3
What are the five resilience patterns presented in the content?
Model answer
The five patterns are timeouts, graceful degradation, retries, exponential backoff, and circuit breakers.
Explanation
These patterns control how an application waits for, substitutes for, repeats, delays, or stops requests when a dependency is failing.
- 4
What practice complements the five resilience patterns?
Model answer
The complementary practice is chaos engineering.
Explanation
Chaos engineering deliberately introduces failures or stress and observes the system so that hidden weaknesses can be found and corrected.
- 5
Describe the request path through the example application.
Model answer
The React application sends a request to a .NET microservice, which acts as a proxy to a third-party joke API. The response travels back through the microservice to the React application for rendering.
Explanation
The .NET service separates the frontend from the external API and uses an HTTP client to make the third-party request.
- 6
What role does the .NET joke client play in the example architecture?
Model answer
The joke client uses an
HttpClientto call the third-party joke API, receive JSON, and serialize the joke data back to the React application.Explanation
The client acts as the integration point between the .NET controller and the external service.
- 7
What information is included in the joke object returned by the API?
Model answer
The joke object contains a setup, a punchline, and a source.
Explanation
The source field can identify whether the response came from the third-party API or from a fallback mechanism.
- 8
What can happen when the third-party API becomes slow and requests have no timeout?
Model answer
Requests can remain waiting, causing additional requests to accumulate. The growing load can delay responses further and eventually overwhelm the .NET microservice.
Explanation
Waiting requests consume resources in the services handling them. Repeated requests to an already overloaded dependency can create a cascading failure.
- 9
What is the purpose of a timeout in a distributed application?
Model answer
A timeout places an upper limit on how long an application waits for a dependency to respond, allowing it to stop waiting when the dependency is too slow.
Explanation
Without a timeout, requests may wait indefinitely and consume resources. A timeout converts excessive waiting into a manageable failure condition.
- 10
How is a basic timeout configured on a .NET
HttpClientin the example?Model answer
The
HttpClient’sTimeoutproperty is set to a time span, such as five seconds.Explanation
If the request takes longer than the configured duration, the client stops waiting and raises a timeout exception.
- 11
What happens when the example request exceeds its five-second timeout?
Model answer
The .NET microservice stops waiting for the third-party API and receives a timeout exception.
Explanation
The basic timeout limits waiting time, but the unhandled exception still needs to be managed by application logic or a resilience library.
- 12
Why might a resilience library be preferred over only configuring the
HttpClienttimeout?Model answer
A resilience library provides more granular control over timeout behavior and allows the timeout to be composed with other policies.
Explanation
The example uses Polly to execute an asynchronous operation with a cancellation token, giving the application more control over the individual task.
- 13
What is Polly, and what role does it play in the example?
Model answer
Polly is a .NET resilience library used to define and compose policies such as timeouts, fallbacks, retries, and circuit breakers.
Explanation
Other programming languages have comparable resilience libraries, but Polly is the library used for the .NET application in the example.
- 14
How does a cancellation token improve control within Polly’s asynchronous timeout policy?
Model answer
A cancellation token allows the application to cancel the individual asynchronous task being executed inside the policy.
Explanation
This provides more precise control over the operation affected by the timeout rather than treating the entire client call as an uncontrolled operation.
- 15
What is graceful degradation?
Model answer
Graceful degradation is the practice of returning a useful fallback response when a dependency fails instead of allowing the whole feature to fail.
Explanation
In the example, the application returns a predefined joke when the third-party API raises an exception or exceeds its timeout.
- 16
How does a Polly fallback policy respond to a failed joke API request?
Model answer
It handles the exception and asynchronously returns a list containing a predefined fallback joke.
Explanation
The fallback joke includes a setup, punchline, and a source indicating that the response came from the fallback.
- 17
Why is the source field useful when implementing graceful degradation?
Model answer
It lets the application or user identify whether the displayed result came from the third-party service or a fallback response.
Explanation
In the demonstration, the source changes to “fallback” when the external request cannot be completed.
- 18
What does it mean to wrap policies in Polly?
Model answer
Wrapping policies combines multiple policies into an ordered policy chain that is applied when the operation executes.
Explanation
The example wraps the fallback with other policies so that failures can be retried or eventually handled by a fallback.
- 19
What is the result when the third-party API becomes slow but later responds successfully?
Model answer
If the request completes within the applicable policy behavior, the application returns the normal response from the third-party API; otherwise, it uses a fallback.
Explanation
Graceful degradation does not replace successful responses. It provides an alternative only when the dependency cannot provide a usable response.
- 20
What is the purpose of a retry policy?
Model answer
A retry policy repeats a failed request a specified number of times in the hope that a temporary failure will resolve.
Explanation
Retries are useful when a dependency fails transiently, but they must be limited and controlled to avoid increasing the load on that dependency.
- 21
How is the retry count used in the example?
Model answer
The retry policy is configured to retry a failed operation up to five times before the fallback policy is used.
Explanation
Each retry is subject to the timeout, so repeated attempts can substantially increase the total time before a final fallback response.
- 22
How do retries, timeouts, and fallbacks work together in the example?
Model answer
Each request is given a limited time to complete; failed attempts are retried up to the configured count, and if all attempts fail, the application returns a fallback response.
Explanation
The policy wrapper establishes an order in which the application first limits waiting, then repeats the operation, and finally degrades gracefully.
- 23
If five retry attempts each have a two-second timeout, how long can the repeated attempts take in total, ignoring other delays?
Model answer
They can take up to ten seconds in total, calculated as 5×2 seconds.
Explanation
Each attempt can consume its full timeout before the next attempt begins. Additional retry delays, if configured, would increase the total duration.
- 24
Why can unrestricted basic retries harm a failing third-party service?
Model answer
Many clients retrying at the same time can generate excessive traffic and act like a distributed denial-of-service attack against the already-failing service.
Explanation
Retries multiply requests during an outage. Without delays or coordination, they can intensify congestion and prevent the dependency from recovering.
- 25
What is exponential backoff, and why is it an improvement over immediate retries?
Model answer
Exponential backoff increases the delay between successive retries, reducing the request load on a failing dependency and giving it time to recover.
Explanation
Instead of retrying at a fixed or immediate interval, the application waits progressively longer after each failure.
- 26
What sequence of retry delays illustrates exponential backoff in the example?
Model answer
The delays increase from two seconds to four seconds, then eight seconds, and finally sixteen seconds.
Explanation
Each delay is multiplied by two, distributing retry traffic over a longer period instead of sending all attempts close together.
- 27
How does exponential backoff distribute load across a third-party API?
Model answer
It spreads requests over increasing time intervals, reducing the concentration of retry traffic while the dependency is under stress.
Explanation
The longer intervals give the third-party service additional time to recover and reduce the chance that clients will overwhelm it.
- 28
How can an exponential backoff delay be generated mathematically?
Model answer
A delay can be calculated using a power of two based on the retry attempt, such as 2n, where n represents the retry attempt.
Explanation
Using powers of two produces the increasing sequence 2, 4, 8, and 16 seconds shown in the example.
- 29
What problem can occur when many clients use the same deterministic exponential backoff schedule?
Model answer
Their retries can cluster at the same times, creating synchronized bursts of traffic that reduce the load-spreading benefit of exponential backoff.
Explanation
If clients calculate identical delays, they may all retry simultaneously after each delay, causing repeated traffic spikes.
- 30
What is jitter in the context of retry policies?
Model answer
Jitter adds a random variation to retry delays so that clients do not all retry at the same time.
Explanation
The example adds a random interval between zero and one thousand milliseconds, introducing up to roughly one second of variation.
- 31
How does jitter reduce retry clustering?
Model answer
By assigning slightly different random delays to clients, jitter spreads their retries across time and reduces synchronized traffic spikes.
Explanation
Jitter makes the exponential backoff schedule less deterministic while preserving its general pattern of increasing delays.
- 32
Compare basic retries, exponential backoff, and exponential backoff with jitter.
Model answer
Basic retries repeat requests with limited delay, exponential backoff increases the delay between attempts, and jitter adds randomness to those increasing delays to prevent retry synchronization.
Explanation
Each technique provides more control over retry traffic, with jitter addressing the additional problem of clients clustering on the same schedule.
- 33
What is a circuit breaker in a resilient application?
Model answer
A circuit breaker stops sending requests to a dependency after a defined failure threshold and returns an alternative response for a specified period.
Explanation
It prevents continued retries against a service that is known to be failing, protecting both the dependency and the calling application.
- 34
Why is a circuit breaker useful even when retries and exponential backoff are already implemented?
Model answer
Retries may remain useless when a dependency is continuously broken, whereas a circuit breaker prevents further requests and removes unnecessary load.
Explanation
Backoff reduces retry frequency, but it still sends requests. A circuit breaker stops the calls entirely while the dependency is failing.
- 35
What circuit-breaking threshold and open duration are used in the example?
Model answer
The circuit opens after five exceptions within one minute and remains open for one minute.
Explanation
Once the threshold is reached, requests are prevented from reaching the third-party API during the configured break period.
- 36
What response does the application return while the circuit breaker is open?
Model answer
It returns a dummy or fallback response instead of sending the request to the third-party API.
Explanation
The circuit-breaker fallback handles the broken-circuit exception and returns a predefined joke.
- 37
How does a circuit-breaker fallback differ from the ordinary exception fallback?
Model answer
The circuit-breaker fallback specifically handles the broken-circuit exception, whereas the ordinary fallback handles general exceptions from failed operations.
Explanation
This distinction allows the application to identify that the circuit has been opened rather than merely reacting to an individual request failure.
- 38
What happens after the circuit-breaker open period expires?
Model answer
The circuit allows requests to reach the endpoint again, so the application can test whether the third-party API has recovered.
Explanation
The circuit breaker is not a permanent shutdown; it temporarily protects the dependency and later permits normal requests to resume.
- 39
Why must the circuit-breaker policy maintain state?
Model answer
It must remember failures across requests so it can determine when the failure threshold has been reached and whether the circuit is currently open.
Explanation
If the policy were recreated for every request, it could lose the history and state required to enforce circuit breaking.
- 40
Why is the policy wrapper moved to a class field or initialized with the client rather than recreated for every request?
Model answer
Keeping the wrapper as shared client state allows circuit-breaker state to persist across method calls and avoids rebuilding the policies for every request.
Explanation
The example initializes the policies when the joke client is constructed so the policy instance can maintain state over time.
- 41
What is chaos engineering?
Model answer
Chaos engineering deliberately injects failures or stress into a system, observes its behavior, and uses the results to improve resilience and performance.
Explanation
It is more than causing failures: observation and learning are essential parts of the practice.
- 42
How did the demonstration use chaos engineering?
Model answer
It injected random failures and delays into the third-party joke API so the application’s resilience patterns could be tested.
Explanation
The controlled failures made it possible to observe timeouts, fallbacks, retries, backoff, and circuit breaking in action.
- 43
What kinds of weaknesses can chaos engineering reveal?
Model answer
It can uncover hidden issues, blind spots, and behaviors that are not known before the system is placed under failure or stress.
Explanation
The observations help developers improve the resilience and performance of the system rather than relying only on assumptions.
- 44
Why is chaos engineering difficult to perform using traditional approaches?
Model answer
Traditional approaches may require stitching together scripts and tools, installing agents or complex libraries, and creating realistic yet controlled test environments.
Explanation
These requirements make experiments harder to start, repeat, and use for reproducing real-world failure conditions.
- 45
Why can testing chaos in a production-like environment be challenging?
Model answer
It is difficult to reproduce realistic events safely, because injecting failures directly into production can unintentionally disrupt real users and services.
Explanation
A useful chaos test should resemble production conditions while remaining controlled enough to avoid unacceptable impact.
- 46
What is the purpose of a fault injection simulator in chaos engineering?
Model answer
It provides a controlled way to inject faults into real system resources so that application behavior under failure can be tested.
Explanation
The simulator reduces the need to create custom failure scripts while still allowing experiments against actual infrastructure.
- 47
How is an experiment defined to stop selected EC2 instances?
Model answer
The experiment uses a
stop instancesaction, targets the desired resources, and specifies that the instances should be stopped for one minute.Explanation
The action and duration define what fault will occur and how long it will persist.
- 48
How do resource tags make a fault-injection experiment more targeted?
Model answer
Tags allow the experiment to select only resources with a specified label, such as instances tagged
API, instead of affecting every instance.Explanation
Targeting by tags limits the blast radius and lets engineers test a particular service or resource group.
- 49
What happened to the tagged EC2 instances during the demonstrated experiment?
Model answer
The selected API instances were stopped for one minute and then became available again after the experiment ended.
Explanation
The experiment created a real infrastructure failure that could be used to evaluate how the application handled unavailable servers.
- 50
Why was a warning given before running the EC2 fault-injection experiment?
Model answer
The experiment affected real services and actually stopped the selected instances rather than simulating the event in a mock environment.
Explanation
Real fault injection can have operational consequences, so experiments must be carefully targeted and controlled.
- 51
What other kinds of actions can a fault-injection simulator support besides stopping servers?
Model answer
It can perform different actions on infrastructure, including controlling container instances when applications use containers.
Explanation
Stopping EC2 instances was only one simple example; fault-injection tools can support multiple resource and failure actions.
- 52
How can the timing of a chaos experiment be controlled?
Model answer
Engineers can define the duration of the fault and schedule experiments for a specific service, time period, or time of day.
Explanation
This granularity allows teams to test selected conditions while limiting the duration and scope of the disruption.

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