Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is the Fallback pattern in microservices?
The Fallback pattern is a design approach where a system provides an alternative response or behavior when a service call fails or is unavailable, ensuring the system remains responsive and stable.
Click to reveal answer
beginner
Why is the Fallback pattern important in distributed systems?
Because services can fail or be slow, the Fallback pattern helps prevent cascading failures by providing a backup response, improving system reliability and user experience.
Click to reveal answer
intermediate
Name two common types of fallback strategies.
1. Returning a default or cached response. 2. Calling a backup service or a simpler version of the service.
Click to reveal answer
intermediate
How does the Fallback pattern relate to the Circuit Breaker pattern?
The Circuit Breaker detects failures and stops calls to a failing service temporarily, while the Fallback pattern provides an alternative response during that time to keep the system responsive.
Click to reveal answer
beginner
What is a risk of not implementing a Fallback pattern in microservices?
Without fallback, a failure in one service can cause delays or failures in others, leading to poor user experience or system crashes.
Click to reveal answer
What does the Fallback pattern do when a service call fails?
ARetries the call indefinitely
BProvides an alternative response or behavior
CShuts down the entire system
DIgnores the failure and continues
✗ Incorrect
The Fallback pattern provides an alternative response or behavior to keep the system responsive when a service call fails.
Which of the following is NOT a common fallback strategy?
AReturning cached data
BCalling a backup service
CReturning a default response
DIncreasing the timeout indefinitely
✗ Incorrect
Increasing the timeout indefinitely is not a fallback strategy; it can cause delays and worsen failures.
How does the Fallback pattern improve user experience?
ABy shutting down services to prevent errors
BBy hiding all errors from users
CBy providing quick alternative responses during failures
DBy logging errors silently
✗ Incorrect
Fallback provides quick alternative responses so users do not face long delays or errors.
Which pattern often works together with Fallback to handle service failures?
ACircuit Breaker
BLoad Balancer
CSingleton
DObserver
✗ Incorrect
Circuit Breaker detects failures and stops calls temporarily, while Fallback provides alternative responses.
What is a potential consequence of not using fallback in microservices?
ACascading failures and poor system stability
BFaster response times
CReduced system complexity
DAutomatic error correction
✗ Incorrect
Without fallback, failures can cascade causing instability and poor user experience.
Explain the Fallback pattern and why it is important in microservices.
Think about what happens when a service is down and how fallback helps.
You got /3 concepts.
Describe how the Fallback pattern works together with the Circuit Breaker pattern.
Consider how these patterns prevent failures from spreading.
You got /3 concepts.
Practice
(1/5)
1. What is the main purpose of the fallback pattern in microservices?
easy
A. To provide a backup response when a service call fails
B. To increase the number of service calls
C. To replace the main service permanently
D. To log all service requests for auditing
Solution
Step 1: Understand the fallback pattern role
The fallback pattern is designed to handle failures gracefully by providing an alternative response.
Step 2: Identify the main goal
Its main goal is to keep the system responsive and avoid cascading failures by returning backup data or default messages.
Final Answer:
To provide a backup response when a service call fails -> Option A
Quick Check:
Fallback pattern = backup response [OK]
Hint: Fallback means backup response on failure [OK]
Common Mistakes:
Thinking fallback increases service calls
Confusing fallback with permanent service replacement
Assuming fallback is for logging only
2. Which of the following is a correct way to implement a fallback method in a microservice?
easy
A. Ignore the failure and return an error to the user
B. Call the main service repeatedly until it succeeds
C. Return cached data or a default message when the main service fails
D. Restart the entire microservice on failure
Solution
Step 1: Review fallback implementation options
Fallback should provide a quick alternative response like cached data or default messages.
Step 2: Eliminate incorrect options
Repeated calls can cause delays, ignoring failure hurts user experience, and restarting service is costly and slow.
Final Answer:
Return cached data or a default message when the main service fails -> Option C
Quick Check:
Fallback = cached or default response [OK]
Hint: Fallback returns cached or default data on failure [OK]
Common Mistakes:
Retrying endlessly instead of fallback
Returning errors instead of fallback data
Restarting services unnecessarily
3. Consider this pseudocode for a microservice call with fallback:
response = callMainService()
if response.failed:
response = fallbackResponse()
print(response)
What will be printed if callMainService() fails?
medium
A. The fallback response
B. The original failed response
C. An error message and no response
D. Nothing, the program crashes
Solution
Step 1: Analyze the failure condition
If callMainService() fails, the code assigns fallbackResponse() to response.
Step 2: Determine printed output
The printed output will be the fallback response, not the failed original response or an error.
Final Answer:
The fallback response -> Option A
Quick Check:
Failed main call triggers fallback output [OK]
Hint: Failed call triggers fallback print [OK]
Common Mistakes:
Assuming failed response is printed
Expecting program crash on failure
Confusing fallback with error message
4. This code snippet tries to implement a fallback but has a bug:
The try block returns the service call result, but except calls fallback without returning it.
Step 2: Identify missing return
Without returning fallback's result, the function returns None on failure instead of fallback data.
Final Answer:
The fallback function is not returned -> Option D
Quick Check:
Missing return in except causes None [OK]
Hint: Always return fallback result in except block [OK]
Common Mistakes:
Forgetting to return fallback data
Misunderstanding try-except flow
Assuming fallback raises error
5. You design a microservice that calls a payment gateway. To avoid delays, you want to use the fallback pattern. Which fallback strategy is best to keep the system responsive and safe?
hard
A. Return a generic error message without fallback
B. Return a cached success response immediately and update later asynchronously
C. Retry the payment gateway call 10 times before fallback
D. Restart the payment microservice on failure
Solution
Step 1: Understand fallback goals for payment service
Fallback should keep system responsive and avoid blocking user with delays.
Step 2: Evaluate options for responsiveness and safety
Returning cached success immediately and updating asynchronously balances responsiveness and eventual consistency.
Step 3: Eliminate risky or slow options
Retries cause delays, generic errors hurt UX, restarting service is costly and slow.
Final Answer:
Return a cached success response immediately and update later asynchronously -> Option B
Quick Check:
Cached immediate fallback with async update = best practice [OK]
Hint: Use cached immediate fallback plus async update [OK]