Decompose by business capability
A business capability is something that a business does in order to generate value.
Capabilities of an online store could include order management, inventory management, shipping, online payment and so on.
It is based on what the business of the organization is.
Each business capability can be thought of as a service and this approach is business oriented.
A business capability or a sub-capability can be a service depending on several factors like whether they are intertwined or represent different phases etc. As the services eveolve, they could be again split into multiple services or even combined.
Decompose by subdomain
This is based on Domain Driven Design (DDD). In DDD, the Software components are mapped to the business domain objects.
This will also help in developing a ubiquitous language that can be used for communication between domain expert, business analyst, software developers and other stake holders.
A business domain can have several subdomains. Sub domains can be very similar to the business Capabilities.
The domain objects can have different meaning in different subdomains and are limited to a bounded context.
Each subdomains can be mapped to a microservice.
Obstacles for decomposing an application into microservices
1. Network latency - Distributed architecture will result in lot of cross-service calls resulting in reduced network latency.
2. Synchronous interprocess communication reduces availability - If one of the dependent service is unavailable, it could result in no processing of data even when the service is Up.
3. Maintaining data consistency across services - With separate database for each service, the update of a dependent business domain will require updates in other microservices. Transactional Messaging and SAGA patterns can be used for solving this scenario.
4. Obtaining a consistent view of the data - Decomposition into multiple services will raise the challenge of combining the data from across multiple services while presenting the data to the user.
API composition and CQRS are two patterns that can be used in these scenarios.
5. God classes prevent decomposition - the resource that is key for each of the service and are bloated with numerous responsibilities.
Use Domain Driven Design (DDD) to use the domain representation of the resource and split it across services using the bounded context in which the domain objects reside (Decompose by subdomain).
No comments:
Post a Comment