0
0
Microservicessystem_design~10 mins

Graceful degradation in Microservices - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to implement a fallback response in a microservice.

Microservices
response = call_service() or [1]
Drag options to blanks, or click blank then click option'
Araise Exception()
B"default response"
CNone
Dexit()
Attempts:
3 left
💡 Hint
Common Mistakes
Raising an exception stops the flow instead of degrading gracefully.
2fill in blank
medium

Complete the code to check service health before calling it.

Microservices
if [1]():
    response = call_service()
else:
    response = "fallback"
Drag options to blanks, or click blank then click option'
Aservice.is_busy
Bservice.is_down
Cservice.is_error
Dservice.is_available
Attempts:
3 left
💡 Hint
Common Mistakes
Using a negative health check leads to wrong logic.
3fill in blank
hard

Fix the error in the circuit breaker pattern code.

Microservices
if circuit_breaker.[1]():
    response = call_service()
else:
    response = "fallback"
Drag options to blanks, or click blank then click option'
Ais_disabled
Bis_open
Cis_closed
Dis_half_open
Attempts:
3 left
💡 Hint
Common Mistakes
Using is_open allows calls when it should block them.
4fill in blank
hard

Fill both blanks to implement a timeout fallback in a microservice call.

Microservices
try:
    response = call_service(timeout=[1])
except [2]:
    response = "fallback"
Drag options to blanks, or click blank then click option'
A5
BTimeoutError
CConnectionError
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong exception type causes fallback not to trigger.
5fill in blank
hard

Fill all three blanks to create a fallback cache mechanism.

Microservices
cache = [1]()
if not cache.has(key):
    data = call_service()
    cache.[2](key, data)
else:
    data = cache.[3](key)
Drag options to blanks, or click blank then click option'
ACacheStore
Bset
Cget
Ddelete
Attempts:
3 left
💡 Hint
Common Mistakes
Using delete instead of get loses cached data.