Kubernetes and Cloud Native Associate (KCNA)Cloud Native ArchitectureMedium
A platform team is designing an API Gateway for a suite of financial microservices. They need to ensure that incoming requests are routed to the correct backend service based on the URL path. For example, requests to `/api/v1/accounts` should go to the 'accounts' service, and `/api/v1/transactions` should go to the 'transactions' service. What routing strategy should the API Gateway employ?
- AQuery parameter-based routing
- BHost-based routing
- CHeader-based routing
- DPath-based routing
Show answer & explanationAnswer & explanation
Correct answer: D. Path-based routing
Path-based routing directs traffic to different backend services or versions based on the URL path in the incoming request. This perfectly matches the requirement to route requests like `/api/v1/accounts` to a specific service.
Why the other options are wrong
- A. Query parameter-based routing uses parameters in the URL query string to route requests, which is not the primary mechanism described.
- B. Host-based routing directs traffic based on the hostname in the request, not the URL path.
- C. Header-based routing uses specific HTTP headers in the request to determine the routing destination.
Path-based Routing
A routing strategy used by API Gateways or load balancers that directs incoming requests to different backend services or endpoints based on the URL path of the request.
- Uses the URI path segment for routing decisions.
- Enables granular control over service exposure.
- Common in microservices architectures.
- Part of API Gateway functionality.
Memory trick: Path points the way for people.