Api Gateway medium
In a dynamic Kubernetes environment where Pod IPs are ephemeral, how does an API Gateway maintain reliable routing to a backend service like 'Shipping'?
- A It performs a global IP scan of the entire subnet for every incoming request to find a service with a matching name.
- B It relies on a hardcoded list of IPs that developers must manually update in a config file during every deployment.
- C It integrates with a Service Registry (e.g., Consul, Eureka, or K8s DNS) to dynamically resolve logical service names into a list of healthy, currently active IP addresses.
- D It uses a predictable IP generation algorithm based on the time the service was started.
Answer: C. It integrates with a Service Registry (e.g., Consul, Eureka, or K8s DNS) to dynamically resolve logical service names into a list of healthy, currently active IP addresses.
In modern cloud-native systems, you can't use static IPs because services are constantly scaling up, down, or moving nodes. The Gateway acts as a client to the Service Discovery system, effectively performing 'Client-Side Load Balancing' by retrieving the latest 'Health Map' of the cluster before routing the 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?