Api Gateway medium
Your Gateway is performing 'Request Aggregation' for 4 services. If 3 services respond in 100ms but the 'Promotions' service times out after 2 seconds, what is the best architectural response?
- A Wait up to 30 seconds for the Promotions service to ensure the data is 100% complete.
- B Return a 504 Gateway Timeout error for the entire request so the user knows something is wrong.
- C Return a 'Partial Response': Send the critical data (User, Orders, Cart) and a null or error indicator for the failed Promotions section.
- D Automatically restart the Promotions service and wait for it to come back online before answering the user.
Answer: C. Return a 'Partial Response': Send the critical data (User, Orders, Cart) and a null or error indicator for the failed Promotions section.
In microservices, 'Partial Failures' are inevitable. A user shouldn't be blocked from seeing their current Shopping Cart just because the 'Recommended Products' service is slow. By returning a partial response, the Gateway maintains high system availability and a better user experience at the cost of slight data incompleteness.
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?