Api Gateway medium
The 'Inventory Service' is experiencing extreme latency and intermittent timeouts. How should an API Gateway with a 'Circuit Breaker' pattern react to protect the rest of the system?
- A It should automatically increase the request timeout to 60 seconds to give the service more 'breathing room'.
- B It should retry every failed request 10 times across different instances to ensure eventual success.
- C It should 'Open' the circuit: immediately returning a 503 error or a cached fallback response without even attempting to call the failing service.
- D It should restart the Inventory Service containers automatically using a shell script.
Answer: C. It should 'Open' the circuit: immediately returning a 503 error or a cached fallback response without even attempting to call the failing service.
This is the 'Fail Fast' principle. If a downstream service is struggling, ongoing requests from the Gateway will consume threads/connections while waiting for timeouts, leading to 'Cascading Failures'. Opening the circuit protects the Gateway's own resources and gives the downstream service time to recover without being hammered by traffic.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- Your Gateway communicates with backends via HTTP/1.1 connections. A slow backend service causes 'Head-of-Line Blocking'. How does switching to HTTP/2 as the Gateway-to-Backend transport mitigate this?
- What is the primary architectural role of an API Gateway in a microservices environment?
- Why is 'Stateless Token Validation' (e.g., using JWTs) significantly more scalable at the Gateway level than 'Stateful Validation' (e.g., using Opaque/Reference Tokens)?
- Your Gateway is configured to cache any URL ending in `.css` or `.jpg`. An attacker tricks a victim into visiting `https://api.com/v1/profile/info/style.css`. How can this lead to an 'Account Takeover'?
- An API is receiving a sudden surge of 10,000 requests per second from a single IP address. How does an API Gateway preserve the stability of the backend services?
- How can an API Gateway help prevent 'Double Charging' in a payment system when a mobile client retries a failed request due to a poor connection?