One of the alternatives for managing common data between microservices is replicating the data needed by multiple services in their own databases but there are large data sets that we do not want to replicate.
I'm using as an example the Food Ordering Application used in the book Microservices Patterns by Chris Richardson where they have these main services:
- Consumer service
- Ordering service
- Kitchen service
- Accounting service
If we wanted a client app to display all of the pending orders we would call the ordering service to get all of the pending orders but the ordering service only stores the orders consumer id and the client needs to display the consumer's full name.
I see two approaches:
- to have the client call a the consumer service for each order received by the order service and look for the consumer full name
- to have the order service expand the data, that is, when the pending orders are requested the order service will call the consumer service to get the consumer's full name and return the data already expanded
Is there a best practice to deal with this? Are any of these approaches frowned upon? Are there other common alternatives that I'm missing?