I'm designing an application using Micro-Services and I'm unsure on the best mechanism to use to collect data from multiple services.
I believe there are two options:
- Integrate an 'inter-service' communication mechanism that allows the services to talk directly. The API Gateway would call an individual service, which then calls other services to collect data, before returning the consolidated response to the API Gateway. The API then returns the response to the caller. (This would have to be synchronous calls when the call to serviceB requires the response from serviceA. I.E Separate Person and Address Services.)
- Have the API Gateway call each service directly and consolidate the data within the API before returning the response.
I'm leaning towards the second option, as having the services talk to each other would introduce coupling, in which case I might as well just architect a monolithic application. However, there are a few serious drawbacks that I can think of off the top of my head with this option:
Having the API executes multiple calls to multiple services increases the load on the API server, especially when some of those calls are blocking.
This method would mean the API has to be aware of what the application is trying to do (I.E Logic would have to be programmed into the API to handle calling the services in turn, and then to consolidate the data), rather than just act as a dumb 'endpoint' for the micro-services.
I'd like to know what the standard approach to this problem is and if there is another third option that I'm missing?