Api Gateway medium
How does an API Gateway facilitate a 'Canary Release' strategy for a new version (v2) of a microservice?
- A It automatically clones the entire production database into a separate v2 database for the test.
- B Weighted Routing: It routes a small, configurable percentage (e.g., 5%) of traffic to v2 while keeping 95% on the stable v1, monitoring for errors before proceeding.
- C It ensures that only users with 'Canary' in their username are allowed to use the new service.
- D It blocks all traffic to v1 to force users to use v2, ensuring the new version is 'battle-tested'.
Answer: B. Weighted Routing: It routes a small, configurable percentage (e.g., 5%) of traffic to v2 while keeping 95% on the stable v1, monitoring for errors before proceeding.
The Gateway acts as a smart valve. By gradually shifting traffic based on percentage or user headers, you can detect 'Regression Bugs' in v2 with minimal blast radius. If v2 starts throwing errors, you simply shift the weight back to 100% on v1 instantly at the Gateway level.
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?