Search code examples
node.jsrabbitmqgraphqlmicroservicesapollo-client

API gateway and microservices communication


I am building microservices arhitecture and i need help with communication. What is best approach for API gateway to communicate with services ? My API gateway will be graphql apollo server and services will be REST APIs. Should i use REST to communicate with services or some message system like RabbitMQ ?


Solution

  • You can do it both ways but using a message broker system like RabbitMQ will give you the advantage of load balancing. With HTTP rest communication, you need a load balancer so that traffic is distributed and routed to the various instances. But with a message broker like RabbitMQ, broker itself is the load balancer. If multiple consumers are listening same address at the same time messages will be delivered parallel instead of blocking each other as the behavior of HTTP. I hope I could explain it clearly :)

    You can look at this article which explains the advantages.