Which instance?
Distributes traffic among multiple instances of the same service to improve scalability and availability.
Lesson 4 · Service routing
The client always calls localhost:7412. The API Gateway reads the HTTP path and decides whether User, Catalog, Inventory, Cart, Order, or Payment Service should handle the request.
Interactive architecture lab
Select different APIs and watch the same gateway route each request to exactly one responsible service.
http://localhost:7412/api/users
Start the lesson, then execute a request through the API Gateway.
Execute a request to inspect the original response.
Execute a request to inspect the response headers.
localhost:7412/api/users → User Servicelocalhost:7412The only API address known by the client.apiGateway1:80Nginx accepts requests here inside Docker.HTTP request pathThe path selects a service type, not a replica.Nginx location rulesEach location forwards to one private upstream.location /api/users { proxy_pass http://user_service; }
location /api/products { proxy_pass http://catalog_service; }
location /api/orders { proxy_pass http://order_service; }
Start the lesson to see routing decisions.
Private upstreams
Observe the routing decision
The gateway selects a service from the request path. It is not choosing among replicas of the same service.
What this teaches
An API Gateway sits in front of backend services and acts as a single entry point for client requests. It examines the request and routes it to the correct service.
Without an API Gateway, the client may need to know the address of every service. With a gateway, the client knows one endpoint while paths such as /api/users, /api/products, and /api/orders select the appropriate backend.
Different decisions
They are often used together, not as replacements for each other.
Distributes traffic among multiple instances of the same service to improve scalability and availability.
Routes requests among different services and APIs, with API-level policies around that routing.
What this gives us
What still remains