32
CHAPTER 3 | Architecting container and microservice-based applications
purpose in another context, and might even have a different name.
For instance, a user can be
referred as a user in the identity or membership context, as a customer in a CRM context, as a
buyer in
an ordering context, and so forth.
The way you identify boundaries between multiple application contexts with a different domain for
each context is exactly how you can identify the boundaries for each business microservice and its
related domain model and data. You always attempt to minimize the coupling between those
microservices. This guide goes into more detail about this identification and
domain model design in
the section
Identifying domain-model boundaries for each microservice
later.
Challenge #2: How to create queries that retrieve data from several
microservices
A second challenge is how to implement queries that retrieve data from several microservices, while
avoiding chatty communication to the microservices from remote client apps. An example could be a
single screen from a mobile app that needs to show user information that’s
owned by the basket,
catalog, and user identity microservices. Another example would be a complex report involving many
tables located in multiple microservices. The right solution depends on the complexity of the queries.
But in any case, you’ll need a way to aggregate information if you want to improve the effi
ciency in
the communications of your system. The most popular solutions are the following.
API Gateway.
For simple data aggregation from multiple microservices
that own different databases,
the recommended approach is an aggregation microservice referred to as an API Gateway. However,
you need to be careful about implementing this pattern, because it can be a choke point in your
system, and it can violate the principle of microservice autonomy. To mitigate this possibility, you can
have multiple fined-grain
ed API Gateways each one focusing on a vertical “slice” or business area of
the system. The API Gateway pattern is explained in more detail in the
API
Gateway section
later.
Dostları ilə paylaş: