We have already explored synchronous and asynchronous ways of communication between microservices and discussed the collaboration style of the services. Those styles were request/response and event-based. Though request/response seems to be synchronous in nature, the truth is that it is the implementation that decides the outcome of the style of integration. Event-based style, on the other hand, is purely asynchronous.
When dealing with a large number of microservices, it is important that we utilize an integration pattern in order to facilitate complex interaction among microservices. We explored the API Gateway along with anĀ event-driven pattern.
API Gateway provides you with a plethora of services, some of which are as follows:
- Routing an API call
- Verifying API keys, JWT tokens, and certificates
- Enforcing usage quotas and rate limits
- Transforming APIs on the fly without code modifications
- Setting up caching backend responses
- Logging call metadata for analytic purposes
The event-driven pattern works by some services publishing their events and some subscribing to those available events. The subscribing services simply react independently of the event-publishing services, based on the event and its metadata. The publisher is unaware of the business logic that the subscribers would be executing.