Skip to main content
Added diagrams
Source Link

Components involved:

  • Mobile Client
  • Microservices
  • API Gateway

Lets say I have 2 microservices for now. Each of them beingmicroservice is 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 assumeOne of the request involves 2 microservicesmost important tasks of the system is to perform the furniture selection and furniture placement algorithms (Service A and Service Bas shown below). The output given by Service B depends onselection takes place first and provides the output of Service Ato the placement algorithm which should give the result to the user.

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.

    The API Gateway sends a request to Selection Algorithm Service. Waits for its response. Once the API Gateway receives the response, it sends a request (along with the response received from the previous request) to the Placement Algorithm Service. Gets the response and returns it to the client. Illustration below:

What is the best way handle the request?enter image description here

  1. The API Gateway sends a request to the Selection Algorithm Service which does the required processing and then sends a request to the Placement Algorithm Service along with the result. Once Placement Algorithm Service completes, it responds back to the Selection Algorithm which sends the response back to the API Gateway and the API Gateway returns it to the client. Illustration below:

enter image description here

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

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?

Components involved:

  • Mobile Client
  • Microservices
  • API Gateway

Each microservice is a Flask application exposing a RESTful API. When a request is made by the mobile client, it is sent to the API Gateway.

One of the most important tasks of the system is to perform the furniture selection and furniture placement algorithms (as shown below). The selection takes place first and provides the output to the placement algorithm which should give the result to the user.

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

  1. The API Gateway sends a request to Selection Algorithm Service. Waits for its response. Once the API Gateway receives the response, it sends a request (along with the response received from the previous request) to the Placement Algorithm Service. Gets the response and returns it to the client. Illustration below:

enter image description here

  1. The API Gateway sends a request to the Selection Algorithm Service which does the required processing and then sends a request to the Placement Algorithm Service along with the result. Once Placement Algorithm Service completes, it responds back to the Selection Algorithm which sends the response back to the API Gateway and the API Gateway returns it to the client. Illustration below:

enter image description here

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

edited tags
Link
Source Link

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?