39
CHAPTER 3 | Architecting container and microservice-based applications
Figure 4-11. Decomposing traditional data models into multiple domain models
When decomposing a traditional data model between bounded contexts, you can have different
entities that share the same identity (a buyer is also a user) with different attributes in each bounded
context. You can see how the user is present in the Conferences Management
microservice model as
the User entity and is also present in the form of the Buyer entity in the Pricing microservice, with
alternate attributes or details about the user when it’s actually a buyer. Each microservice or BC might
not need all the data related to a User entity, just part of it, depending on the problem to solve or the
context.
For instance, in the Pricing microservice model, you do not need the address or the name of
the user, just the ID (as identity) and Status, which will have an impact on discounts when pricing the
seats per buyer.
The Seat entity has the same name but different attributes in each domain model. However, Seat
shares identity based on the same ID, as happens with User and Buyer.
Basically, there’s a shared concept of a user that exists in multiple services (domains), which all share
the identity of that user. But in each domain model there might be additional or different
details
about the user entity. Therefore, there needs to be a way to map a user entity from one domain
(microservice) to another.
There are several benefits to not sharing the same user entity with the same number of attributes
across domains. One benefit
is to reduce duplication, so that microservice models do not have any
data that they do not need. Another benefit is having a primary microservice that owns a certain type
of data per entity so that updates and queries for that type of data are driven only by that
microservice.
40
CHAPTER 3 | Architecting container and microservice-based applications
The API gateway pattern
versus the Direct client-to-
microservice communication
In a microservices architecture, each microservice exposes a set of (typically) fine-grained endpoints.
This fact can impact the client-to-microservice communication, as explained in this section.
Dostları ilə paylaş: