Api Gateway medium
A 'Cache Stampede' occurs when a popular resource (e.g., a viral tweet) expires from the cache and 10,000 users request it at the same microsecond. How does 'Request Coalescing' at the Gateway solve this?
- A It identifies the identical requests, sends ONLY ONE request to the backend, and serves that single response to all 10,000 waiting clients.
- B It automatically extends the cache expiration time by 10 hours for any item that is requested more than twice.
- C It distributes the 10,000 requests across different databases to balance the load.
- D It requires the users to solve a CAPTCHA to prove they are human before it fetches the data.
Answer: A. It identifies the identical requests, sends ONLY ONE request to the backend, and serves that single response to all 10,000 waiting clients.
This is a massive database saver. Instead of the database getting crushed by 10,000 identical 'Select' queries, it only sees one. The Gateway holds the connections 'In-Flight' until the first response returns, then multiplexes it to everyone.
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?