API Gateway pattern for routing. Use for microservices entry.
An API Gateway sits between clients (Mobile, Web) and services. It acts as a reverse proxy, accepting all API calls, aggregating the various services required to fulfill them, and returning the appropriate result.
GET /users -> User Service
GET /orders -> Order Service
Combining results. One request to Gateway -> Calls User Service + Order Service -> Returns combined JSON.
Creating specific gateways for different clients (e.g., one for Mobile with small payloads, one for Web with rich payloads).
Do:
Don't:
| Error | Cause | Solution |
|---|---|---|
502 Bad Gateway | Upstream service down or unreachable. | Check internal service health and firewall rules. |
504 Gateway Timeout | Upstream taking too long. | Optimize service or increase timeout (carefully). |