1
votes

I am writing a microservice app by spring boot and spring cloud. I have five modules which are

  • API-Gateway (base on spring cloud gateway spect)
  • Discovery-Server (base on spring cloud Netflix Eureka service discovery)
  • Microservice-A (It is a spring boot app that includes our business)
  • Microservice-B (It is a spring boot app that includes our business)
  • Microservice-C (It is a spring boot app that includes our business)

All requests which come from users route to API gateway and through API gateway send to app A or B or C (these are not exposed out). Now I have a question, base on one business role, app A will need to call one rest endpoint of app B. Which approach is the best? I call app B endpoint from app A directly or I call by API-Gateway?

2

2 Answers

1
votes

The API Gateway should serve as an ingress layer, it only accepts traffic which is coming from outside of your application (clients / external integrations). More details here.

Any internal communication between your microservices, should be a point-to-point interaction, that can be done in multiple ways. This answer describes that in more details.

So the API Gateway should not be concerned with orchestration of the microservices.

0
votes

If I were you I'll use a message broker for microservices communication. Let the api gateway for external clients. I think we overuse the http protocol. With a microservice architecture we should try to think differently.