Skip to main content
1 of 3

Communication in a microservices architecture with flask and REST

Components involved:

  • Mobile Client
  • Microservices
  • API Gateway

Lets say I have 2 microservices for now. Each of them being a Flask application exposing a RESTful API. When a request is made by the mobile client, it is sent to the API Gateway.

Let us assume the request involves 2 microservices (Service A and Service B). The output given by Service B depends on the output of Service A.

Once the API Gateway has the request, I have 2 options:

  1. The API Gateway sends a request to Service A. Waits for its response. Once it receives the response, it sends a request to Service B. Gets the response and returns it to the client.

  2. The API Gateway sends a request to Service A. Service A does the required processing and then sends a request to Service B. When Service B responds, Service A sends response to the API Gateway and the API Gateway returns it to the client.

What is the best way handle the request?

Also, if at all 2 microservices wanted to communicate with each other, what method would be used?