SinLok
SinLok

Reputation: 609

Best practice for micro-service joining

Case 1 one to many:

Card and User are 2 different micro-services

For example Each Card entity contains 1 UserID.

  1. Frontend call 2 APIs sequencely (i.e. Call Card API -> Call User API by Card.UserID)
  2. Card micro-service call User API by UserID and then return joined result. Frontend only need to call Card API

Which one is the best?

Case 2 many to many: If I need to join many to many in 2 micro-services, what is the best practice?

Upvotes: 0

Views: 200

Answers (1)

pavithra renganathan
pavithra renganathan

Reputation: 11

To answer your question in one line, the best practice is to avoid interdependencies between microservices.

Based on my experience I have listed below the options, which needs to be chosen based on the performance & fault tolerance that your system should meet

  1. Your front end to call card api and then user api

  2. Consider user service as a component - if your user service is always going to be consumed by another microservice, then this would be a better option

Upvotes: 1

Related Questions