Complete the code to identify the common cause of microservices failure related to network issues.
if service_response.status_code == [1]: retry_request()
503 Service Unavailable indicates the service is temporarily unable to handle the request, often due to network or overload issues.
Complete the code to implement a retry mechanism with exponential backoff in microservices communication.
for attempt in range(max_retries): try: call_service() break except NetworkError: sleep([1] ** attempt)
Exponential backoff commonly uses base 2 to increase wait time exponentially after each retry.
Fix the error in the circuit breaker pattern implementation to prevent cascading failures.
if failure_count > [1]: open_circuit() else: call_service()
A threshold like 5 failures is typical to open the circuit and stop calls temporarily.
Fill both blanks to correctly implement a health check for a microservice.
def health_check(): response = requests.get('[1]') return response.status_code == [2]
The health endpoint is commonly '/health' and a 200 status code means service is healthy.
Fill all three blanks to implement a timeout and fallback in a microservice call.
try: response = call_service(timeout=[1]) except TimeoutError: response = [2]() if response.status_code == [3]: process_response(response)
Timeout is set to 5 seconds, fallback_service is called on timeout, and 200 status means success.