API Gateway 00:00:01 Follow one cart request A phone sends one request for its cart. The shopping service has several internal destinations behind one public address. Which decisions belong at the entrance, and which still have to happen near the cart itself? The app sends GET /api/cart to the one public address. It verifies the token and knows the user. The user is within the limit. The gateway picks a healthy copy of the cart service. The request goes on with the verified user ID. The answer returns through the gateway, which logs the call. Let the public address stay stable while the gateway picks an internal route. A useful trace connects the request that arrived at the edge with the downstream operation it triggered. 00:00:49 Choose a service intentionally Products owns /products, /categories and /search. Cart owns /cart, /cart/items and /cart/checkout. Orders owns /orders and everything below it. Users owns /users and /auth. Login is public, with a strict limit. No prefix matches. The gateway answers 404 and no service is disturbed. Route by an explicit combination of host, method and path as required. Keep precedence and fallback rules testable, especially when broad prefixes overlap a more specific endpoint. 00:01:30 Order shared checks The address is not on the block list. Only 12 of 300 requests this minute. Ann used 40 of 100. The token allows changing the cart. All six passed. Its token has expired. The gateway stops there and no service works for it. Authentication can establish caller identity before policy or quota decisions that depend on it. Cheap independent traffic protection can run earlier to avoid spending more expensive work on overload. 00:02:01 Fit the response to the caller The mobile BFF returns thumbnails, a cart count and unread notifications. The web BFF returns full products with reviews and the whole cart. The partner BFF offers a stable versioned API with limits. Products and cart are shared. Rules stay there, so they are not copied three times. A mobile-specific aggregation can save latency and bytes for the phone. It also creates a failure and timeout policy for every backend included in the combined response. 00:02:32 Establish trusted identity downstream Unverified request metadata describes a claimed identity. At this point the server has no independently established reason to trust it. The gateway removes incoming identity assertions at the public boundary. It then validates the credential issued for this service. On an authenticated internal connection the gateway forwards the verified principal. The service independently decides whether that principal may access the requested cart. Resource authorization remains with the service that actually owns the resource. 00:03:04 Lose one gateway instance Each gateway takes 3,000 a second. Gateway B stops. The balancer's health check notices. The other two take 4,500 each. If one copy handles only 4,000, this is too much: run four. Size the surviving gateway instances for the redirected traffic, and include discovery, load balancing and shared rate-limit dependencies in the rehearsal. Healthy backend servers cannot serve a public endpoint nobody can reach. A gateway can centralize routing and shared checks. The cart service still owns the cart, and the gateway itself now lies on an availability path customers cannot bypass.