0
votes

We want to show alternate of a product like most of the e-commerce websites does. In our case, we need to fetch data from multiple microservices.

  • Products - Stores all product information
  • Prices - In our case prices are complex and subject to user's location and other parameters. Hence we made it a separate microservice.
  • Reviews - It manages ratings and reviews about a product.

The end product will be List<AlternateProduct> which would have an image, description, rating out of 5 and a number of reviews.

In microservice architecture, what is the right place to compose a response from multiple microservices?

Approatch 1:

  • MVC/Rest API approaches APIGateway
  • API Gateway make an async call to all microservices
  • The response will be returned to MVC/WebAPI. Where the composition of response can be performed.

Approatch 2:

  • MVC/Rest API approaches APIGateway
  • API Gateway make an async call to Products microservice.
  • Products microservice will call other microservice and perform composition and returns List<UlternateProduct>

Please help me decide!

1
Don't you think my answer is good enough? :)Burim Hajrizaj

1 Answers

0
votes

In this case I would go for Approach 1 sine you can download the list of Products you need and than run 2 other request in parallel for downloading Prices and Reviews.

After your receive response from all 3 requests than you build the model and return it.

I think that Gateway API should be smart enough to make calls to different services and build the result that need to return.