Implementing the API gateway
To further the earlier discussion on dynamic network locations in the microservices architecture, we will focus on the API gateway now. The API gateway is an orchestrator service meant to provide unified, ubiquitous access to all the services. Though we can have multiple microservices running in the backend, an API gateway can provide a unified interface for the upstream consumers to access them. For the upstream consumers, the API gateway appears to be the only service running in the backend. On receiving a client request, the API gateway determines which service instance to call using service discovery.
In order to learn how to implement the API gateway, we will add an API gateway service to the pet-clinic
application. Since this microservice is an orchestrator service, we can call it pet-clinic-concierge
. The system components after the gateway service would be as seen in Figure 7.6: