1. Home
  2. Explore
  3. Computer Science
  4. Resilient Application Design Patterns

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Resilient Application Design Patterns

  • 40Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Resilience Principles

What principle is expressed by the statement that failures are given and everything will eventually fail?

40 questions

  1. 1

    What principle is expressed by the statement that failures are given and everything will eventually fail?

    1. A

      Distributed applications should be designed with inevitable component failures in mind

    2. B

      Distributed applications should replace every failed component immediately

    3. C

      Distributed applications should assume that failures occur only during deployments

    4. D

      Distributed applications should avoid using more than one hardware component

    Correct answer
    A

    Distributed applications should be designed with inevitable component failures in mind

    Explanation

    Modern distributed applications depend on many hardware components, networks, and software stacks, any of which can eventually fail. Resilient systems anticipate those failures and recover from them.

  2. 2

    Why can a failure in one component affect a distributed cloud application?

    1. A

      The application automatically converts every local failure into a database failure

    2. B

      The application cannot communicate between components hosted in different locations

    3. C

      The application may depend on multiple interconnected hardware, network, and software components

    4. D

      The application can run only when every component uses identical hardware

    Correct answer
    C

    The application may depend on multiple interconnected hardware, network, and software components

    Explanation

    Distributed applications span different hardware, networks, and technology stacks. A failure in any dependency can affect requests unless the application is designed to handle that failure.

  3. 3

    What is the main goal of designing for failure in a distributed application?

    1. A

      To allow the application to recover and continue serving users when a component fails

    2. B

      To make every request wait until the failed component becomes available again

    3. C

      To prevent all components from ever experiencing faults or delays

    4. D

      To remove all third-party services from the application architecture

    Correct answer
    A

    To allow the application to recover and continue serving users when a component fails

    Explanation

    The purpose of resilience patterns is not to eliminate failures, but to help the application recover and continue providing service when failures occur.

  4. 4

    Which set correctly identifies the five resilience patterns discussed?

    1. A

      Caching, sharding, replication, compression, and authentication

    2. B

      Load balancing, encryption, logging, batching, and serialization

    3. C

      Timeouts, graceful degradation, retries, exponential backoff, and circuit breakers

    4. D

      Polling, inheritance, inheritance, indexing, and failover clustering

    Correct answer
    C

    Timeouts, graceful degradation, retries, exponential backoff, and circuit breakers

    Explanation

    The five patterns presented are timeouts, graceful degradation, retries, exponential backoff, and circuit breakers. Chaos engineering was presented as a practice rather than one of the five patterns.

  5. 5

    How does chaos engineering differ from merely injecting failures?

    1. A

      It focuses exclusively on measuring application response time

    2. B

      It replaces resilience testing with permanent production outages

    3. C

      It injects or stresses systems and observes their behavior to improve resilience

    4. D

      It injects failures but avoids collecting information about system behavior

    Correct answer
    C

    It injects or stresses systems and observes their behavior to improve resilience

    Explanation

    Chaos engineering involves introducing faults or stress, observing how the system behaves, and using the findings to improve resilience and performance.

  6. 6

    What is the request flow in the demonstrated application?

    1. A

      The .NET microservice calls the React app, which then acts as a proxy to the third-party API

    2. B

      The third-party API calls the React app, which directly stores the response in the database

    3. C

      The React app calls a .NET microservice, which proxies the request to a third-party joke API

    4. D

      The React app calls the third-party API directly, bypassing the .NET microservice

    Correct answer
    C

    The React app calls a .NET microservice, which proxies the request to a third-party joke API

    Explanation

    The React application sends requests to the .NET controller. The controller's joke client calls the third-party joke API and returns the serialized result to the React app.

  7. 7

    What role does the .NET joke client play in the application?

    1. A

      It stores all jokes locally and prevents communication with external services

    2. B

      It injects random failures into the third-party API before every request

    3. C

      It calls the third-party joke API and proxies the JSON response to the React application

    4. D

      It renders the joke table and manages the React application's user interface

    Correct answer
    C

    It calls the third-party joke API and proxies the JSON response to the React application

    Explanation

    The .NET controller defines a joke client that uses an HttpClient to call the third-party joke API, receive JSON, and serialize it back to the React application.

  8. 8

    Which fields are included in the joke object returned by the API?

    1. A

      Client, controller, and endpoint

    2. B

      Setup, punchline, and source

    3. C

      Request, response, and status

    4. D

      Title, author, and timestamp

    Correct answer
    B

    Setup, punchline, and source

    Explanation

    The serialized joke object contains a setup, a punchline, and a source field.

  9. 9

    What problem occurs when the third-party joke API becomes slow and requests have no timeout?

    1. A

      Requests immediately receive fallback jokes without requiring any additional policy

    2. B

      The React application automatically cancels every request before reaching the microservice

    3. C

      Requests wait indefinitely, accumulate under load, and may eventually bring down the microservice

    4. D

      The third-party API stops receiving requests because the microservice rejects them immediately

    Correct answer
    C

    Requests wait indefinitely, accumulate under load, and may eventually bring down the microservice

    Explanation

    Without a timeout, the microservice and the React application can wait for slow responses. Additional requests can accumulate, increase load, and potentially bring down the microservice.

  10. 10

    What does a five-second HTTP client timeout do?

    1. A

      It returns a fallback response immediately after five seconds without an exception

    2. B

      It guarantees that the third-party API will respond within five seconds

    3. C

      It retries every request exactly five times after five seconds

    4. D

      It causes a request taking longer than five seconds to time out

    Correct answer
    D

    It causes a request taking longer than five seconds to time out

    Explanation

    Setting the HttpClient timeout to five seconds limits how long the client waits. A request that exceeds that duration times out and produces a timeout exception.

  11. 11

    What is the primary purpose of a timeout in a dependent service call?

    1. A

      To increase the amount of time a dependency can hold application resources

    2. B

      To prevent a request from waiting indefinitely for a slow or unavailable dependency

    3. C

      To replace all error-handling logic with a fixed response

    4. D

      To ensure that every dependency call succeeds on its first attempt

    Correct answer
    B

    To prevent a request from waiting indefinitely for a slow or unavailable dependency

    Explanation

    Timeouts bound the waiting period for a dependency call, preventing stalled requests from consuming resources indefinitely.

  12. 12

    What advantage does using Polly for a timeout provide over only setting the HttpClient timeout?

    1. A

      It provides finer-grained control over asynchronous execution and cancellation

    2. B

      It changes the React application into a synchronous application

    3. C

      It guarantees that the external API never throws an exception

    4. D

      It eliminates the need to specify any timeout duration

    Correct answer
    A

    It provides finer-grained control over asynchronous execution and cancellation

    Explanation

    Polly can wrap the request in an asynchronous policy and expose a cancellation token, giving the application more granular control over the timed operation.

  13. 13

    What is the purpose of the cancellation token used inside Polly's asynchronous timeout function?

    1. A

      It stores the joke source returned by the third-party API

    2. B

      It allows the individual asynchronous task to be cancelled when appropriate

    3. C

      It determines which React component renders the response

    4. D

      It increases the timeout duration after every failed request

    Correct answer
    B

    It allows the individual asynchronous task to be cancelled when appropriate

    Explanation

    The cancellation token gives the application control over the asynchronous task inside the policy, including cancelling that task when the timeout is reached.

  14. 14

    What is graceful degradation in the demonstrated application?

    1. A

      Sending failed requests to the third-party API repeatedly without changing the response

    2. B

      Returning a predefined fallback joke when the normal API policy encounters an exception

    3. C

      Allowing the React interface to remain permanently frozen until the API recovers

    4. D

      Disabling the entire application whenever an external dependency fails

    Correct answer
    B

    Returning a predefined fallback joke when the normal API policy encounters an exception

    Explanation

    The fallback policy returns a predefined joke when the normal request policy raises an exception, allowing the application to continue responding.

  15. 15

    Which source value indicates that the returned joke came from the graceful-degradation fallback?

    1. A

      The source field is set to "third party API"

    2. B

      The source field is set to "circuit breaker"

    3. C

      The source field is set to "timeout"

    4. D

      The source field is set to "fallback"

    Correct answer
    D

    The source field is set to "fallback"

    Explanation

    The fallback joke uses the source value "fallback," allowing the user interface to show that a fallback response was returned.

  16. 16

    How are multiple Polly policies combined in the demonstrated design?

    1. A

      They are wrapped together so that policies execute in a defined order

    2. B

      They are compiled into the React component instead of the .NET service

    3. C

      They are placed in separate applications that cannot affect one another

    4. D

      They are randomly selected so that only one policy runs per application

    Correct answer
    A

    They are wrapped together so that policies execute in a defined order

    Explanation

    A policy wrapper combines policies and establishes their order of precedence. In the example, a failed request can move through timeout, retry, and fallback behavior.

  17. 17

    What does a retry policy do after a request fails?

    1. A

      It attempts the request again according to a configured retry count

    2. B

      It immediately returns a successful response without contacting the dependency

    3. C

      It permanently opens a circuit and blocks every later request

    4. D

      It increases the original request timeout without making another attempt

    Correct answer
    A

    It attempts the request again according to a configured retry count

    Explanation

    A retry policy specifies how many additional attempts should be made after an exception or other configured failure.

  18. 18

    In the demonstrated retry configuration, what happens after the configured retries fail?

    1. A

      The retry count resets and the application begins unlimited retries

    2. B

      The application waits forever for the original request to complete

    3. C

      The policy wrapper proceeds to the graceful-degradation fallback

    4. D

      The React application directly contacts the third-party API

    Correct answer
    C

    The policy wrapper proceeds to the graceful-degradation fallback

    Explanation

    The policies are combined so that the request is retried, and if those attempts still fail, the fallback policy returns a predefined joke.

  19. 19

    If each retry attempt has a two-second timeout and five attempts are made sequentially, what is the maximum waiting time before fallback, ignoring other delays?

    1. A

      Twenty-five seconds

    2. B

      Two seconds

    3. C

      Five seconds

    4. D

      Ten seconds

    Correct answer
    D

    Ten seconds

    Explanation

    Five attempts multiplied by a two-second timeout gives 5×2=105 \times 2 = 105×2=10 seconds before the fallback is reached, assuming each attempt times out.

  20. 20

    Why can a basic retry policy create a distributed denial-of-service-like effect?

    1. A

      Many clients may permanently cache successful responses and stop contacting the service

    2. B

      Retries reduce the number of total requests received by the third-party service

    3. C

      Many clients may repeatedly send requests to an already overloaded third-party service

    4. D

      Retries prevent clients from sending any request after the first failure

    Correct answer
    C

    Many clients may repeatedly send requests to an already overloaded third-party service

    Explanation

    If many clients retry rapidly, their repeated requests can increase the load on an already unhealthy dependency, resembling a distributed denial-of-service attack.

  21. 21

    What distinguishes graceful degradation from retrying?

    1. A

      Graceful degradation applies only to successful calls, whereas retrying applies only to user interfaces

    2. B

      Graceful degradation changes request timing, whereas retrying changes the response format

    3. C

      Graceful degradation always makes more dependency calls, whereas retrying stops immediately

    4. D

      Graceful degradation supplies an alternative response, whereas retrying attempts the dependency again

    Correct answer
    D

    Graceful degradation supplies an alternative response, whereas retrying attempts the dependency again

    Explanation

    Retries seek a successful response by making additional attempts. Graceful degradation allows the application to continue by returning an alternative, such as a predefined joke.

  22. 22

    How does exponential backoff improve on immediate retries?

    1. A

      It increases the delay between attempts, helping distribute load over time

    2. B

      It removes all delays so that failures are detected immediately

    3. C

      It replaces failed requests with permanent cached responses

    4. D

      It sends all retry attempts simultaneously to maximize throughput

    Correct answer
    A

    It increases the delay between attempts, helping distribute load over time

    Explanation

    Exponential backoff increases the waiting period between retries, reducing the concentration of requests against an unhealthy dependency.

  23. 23

    Which sequence represents the example exponential-backoff delays?

    1. A

      Two seconds, four seconds, eight seconds, and sixteen seconds

    2. B

      One second, two seconds, three seconds, and four seconds

    3. C

      Sixteen seconds, eight seconds, four seconds, and two seconds

    4. D

      Five seconds, five seconds, five seconds, and five seconds

    Correct answer
    A

    Two seconds, four seconds, eight seconds, and sixteen seconds

    Explanation

    The example doubles the delay after each failed attempt: two, four, eight, and sixteen seconds.

  24. 24

    What does the mathematical factor in the exponential-backoff implementation control?

    1. A

      It determines how many clients may connect to the React application

    2. B

      It determines how the delay grows between successive retry attempts

    3. C

      It determines how many fields are serialized in the response

    4. D

      It determines which joke is selected from the fallback list

    Correct answer
    B

    It determines how the delay grows between successive retry attempts

    Explanation

    The implementation uses a power-based calculation so that the wait duration grows exponentially as the retry attempt number increases.

  25. 25

    Why can exponential backoff alone still allow retry requests to cluster?

    1. A

      Exponential backoff forces every client to retry continuously without waiting

    2. B

      Clients using the same deterministic schedule may retry at approximately the same times

    3. C

      Clients using exponential backoff never perform more than one retry

    4. D

      Exponential backoff sends retries only after the dependency has recovered

    Correct answer
    B

    Clients using the same deterministic schedule may retry at approximately the same times

    Explanation

    If many clients calculate identical deterministic delays, their retries can become synchronized or clustered, reducing the load-spreading benefit.

  26. 26

    What is the purpose of adding jitter to exponential backoff?

    1. A

      To ensure that all retries occur before the first timeout

    2. B

      To make every client retry at exactly the same scheduled time

    3. C

      To introduce randomness that spreads retry attempts across different times

    4. D

      To eliminate the need for a maximum retry count

    Correct answer
    C

    To introduce randomness that spreads retry attempts across different times

    Explanation

    Jitter adds a random component to the exponential delay, reducing synchronized retry clusters and spreading load across time.

  27. 27

    In the demonstrated jitter implementation, what range of random additional delay is used?

    1. A

      A random value between zero and one thousand milliseconds

    2. B

      A fixed value between zero and one millisecond

    3. C

      A fixed value between five and ten seconds

    4. D

      A random value between one thousand and five thousand seconds

    Correct answer
    A

    A random value between zero and one thousand milliseconds

    Explanation

    The example adds a random time span measured in milliseconds, selected between zero and one thousand milliseconds, or up to one second.

  28. 28

    What problem does a circuit breaker address after retries have repeatedly failed?

    1. A

      It increases the number of calls sent to the broken dependency

    2. B

      It prevents further calls from adding load to a dependency that remains broken

    3. C

      It guarantees that the next dependency call will succeed

    4. D

      It removes the need for any fallback response

    Correct answer
    B

    It prevents further calls from adding load to a dependency that remains broken

    Explanation

    A circuit breaker stops sending requests to a failing service after a threshold is reached, preventing useless retries and additional load.

  29. 29

    What response does the circuit breaker return while the circuit is open?

    1. A

      The original request indefinitely until the third-party API responds

    2. B

      A response containing only the third-party API's exception details

    3. C

      A new request sent directly from the React application

    4. D

      A configured dummy or fallback response without calling the third-party API

    Correct answer
    D

    A configured dummy or fallback response without calling the third-party API

    Explanation

    When the circuit is open, requests are short-circuited and a configured fallback response is returned instead of contacting the failing dependency.

  30. 30

    In the demonstrated circuit-breaker configuration, when does the circuit open?

    1. A

      After every request exceeds a timeout of sixteen minutes

    2. B

      After one exception occurs within a five-minute period

    3. C

      After five exceptions occur within a one-minute period

    4. D

      After five successful responses occur within a one-minute period

    Correct answer
    C

    After five exceptions occur within a one-minute period

    Explanation

    The example configures the circuit breaker to open when five exceptions occur within one minute.

  31. 31

    How long does the demonstrated circuit breaker remain open?

    1. A

      Five minutes

    2. B

      Until the application is redeployed

    3. C

      One minute

    4. D

      Ten seconds

    Correct answer
    C

    One minute

    Explanation

    After the failure threshold is reached, the circuit breaker blocks calls for one minute before allowing endpoint calls again.

  32. 32

    Why must the circuit-breaker policy preserve state across requests?

    1. A

      It must remember failures and the current circuit state across individual method calls

    2. B

      It must ensure that every request uses a newly constructed policy

    3. C

      It must store every joke so the React application can render the table

    4. D

      It must preserve the HTTP response body between unrelated users

    Correct answer
    A

    It must remember failures and the current circuit state across individual method calls

    Explanation

    A circuit breaker depends on accumulated failure information and state such as whether the circuit is open. Therefore, the policy wrapper must persist across requests rather than being recreated for every call.

  33. 33

    What distinguishes the circuit-breaker fallback from the ordinary exception fallback?

    1. A

      It retries the third-party API without checking circuit state

    2. B

      It handles only successful responses from the third-party API

    3. C

      It is invoked only when the React component fails to render

    4. D

      It specifically handles a broken-circuit exception raised when the circuit is open

    Correct answer
    D

    It specifically handles a broken-circuit exception raised when the circuit is open

    Explanation

    The circuit-breaker fallback is configured to handle the specific broken-circuit exception, indicating that the circuit breaker has been invoked.

  34. 34

    What is the main objective of chaos engineering?

    1. A

      To uncover hidden system weaknesses and improve resilience and performance

    2. B

      To test only whether a user interface can display an error message

    3. C

      To replace application monitoring with random infrastructure changes

    4. D

      To create unpredictable outages without observing their consequences

    Correct answer
    A

    To uncover hidden system weaknesses and improve resilience and performance

    Explanation

    Chaos engineering exposes blind spots by deliberately introducing realistic faults or stress, observing the system, and using the results to improve it.

  35. 35

    Why can traditional chaos-engineering practices be difficult to implement?

    1. A

      They prevent engineers from selecting which service should be affected

    2. B

      They require no infrastructure access or test planning

    3. C

      They automatically provide realistic experiments in every environment

    4. D

      They may require stitching together scripts, tools, agents, and complex libraries

    Correct answer
    D

    They may require stitching together scripts, tools, agents, and complex libraries

    Explanation

    Traditional approaches can involve assembling multiple scripts and tools or installing agents and libraries, making experiments difficult to set up and reproduce.

  36. 36

    Why is injecting chaos directly into production potentially problematic?

    1. A

      It prevents engineers from observing any system behavior under stress

    2. B

      It guarantees that all hidden issues will remain undetected

    3. C

      It makes targeted experiments impossible in every cloud environment

    4. D

      It can disrupt real users and services if the experiment is not carefully controlled

    Correct answer
    D

    It can disrupt real users and services if the experiment is not carefully controlled

    Explanation

    Production experiments affect real services and may affect users. This is why controlled, targeted experiments and appropriate environments are important.

  37. 37

    How does a fault injection simulator help conduct chaos experiments?

    1. A

      It replaces the application with a mock that cannot experience real failures

    2. B

      It limits experiments to simulated failures that never affect infrastructure

    3. C

      It provides controlled actions for injecting faults into targeted resources

    4. D

      It automatically repairs every failed resource before the experiment begins

    Correct answer
    C

    It provides controlled actions for injecting faults into targeted resources

    Explanation

    The fault injection simulator can perform real actions on selected infrastructure, such as stopping targeted EC2 instances for a specified duration.

  38. 38

    In the demonstrated experiment, how were the target API instances selected?

    1. A

      They were selected using a tag identifying the API servers

    2. B

      They were selected by matching the content of returned jokes

    3. C

      They were selected randomly from all available cloud resources

    4. D

      They were selected by choosing every instance in every account

    Correct answer
    A

    They were selected using a tag identifying the API servers

    Explanation

    The API server EC2 instances were tagged with an API tag, allowing the experiment to target those instances specifically.

  39. 39

    What action did the demonstrated fault-injection experiment perform?

    1. A

      It permanently deleted every targeted EC2 instance

    2. B

      It redirected every targeted instance to a different joke API

    3. C

      It stopped the targeted EC2 instances for one minute

    4. D

      It increased the CPU capacity of the targeted EC2 instances

    Correct answer
    C

    It stopped the targeted EC2 instances for one minute

    Explanation

    The experiment used a stop-instances action on the tagged API servers and specified that they remain stopped for one minute.

  40. 40

    What benefit does targeted, time-bounded fault injection provide?

    1. A

      It prevents engineers from reproducing realistic infrastructure failures

    2. B

      It ensures that every service fails simultaneously for an unlimited period

    3. C

      It removes the need to observe application behavior during the experiment

    4. D

      It allows engineers to test specific services during a defined period with controlled scope

    Correct answer
    D

    It allows engineers to test specific services during a defined period with controlled scope

    Explanation

    Experiments can target particular resources and define how long the fault lasts, enabling more controlled and granular resilience testing.

Question 1 of 40
Question 1 of 40

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent