Api Gateway hard
You use Open Policy Agent (OPA) for complex, fine-grained attribute-based access control (ABAC). Why is deploying OPA as a 'Sidecar' on the Gateway instance strictly superior to calling a centralized OPA 'Policy Server'?
- A Sidecars use the exact same CPU cores as the Gateway, allowing them to share memory without using the network stack.
- B Latency Minimization: Policy evaluation is on the 'Critical Path' of every request. A network call to a central server adds 20-50ms; a sidecar call over the loopback interface adds <1ms, protecting the system's P99 latency.
- C Sidecars are immune to DDoS attacks because they don't have an IP address.
- D Centralized servers are incapable of parsing JSON-based policy documents.
Answer: B. Latency Minimization: Policy evaluation is on the 'Critical Path' of every request. A network call to a central server adds 20-50ms; a sidecar call over the loopback interface adds <1ms, protecting the system's P99 latency.
In high-throughput Gateways, the 'Latency Budget' for authorization is tiny. Moving the 'Policy Decision Point' (PDP) as close as possible to the 'Policy Enforcement Point' (PEP/Gateway) is essential. A sidecar ensures that the authorization logic for every single API call is fast and reliable, even if the central network is congested.
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?