Having recently looked into the enormous topic of microservice architecture, I decided to do a lightening talk about a very small aspect that I thought was interesting - Decomposition Patterns.
What is "decompositon"?
As you can probably guess, it is the breaking down of a large monolith.
Why break down a large monolith?
Scalability, maintainability, and modularity.
When you have a monolith, if a specific area receives bulk of the traffic, you can't just scale up that area. With microservices, you can scale up areas that receive a high load, and scale down the rest, etc.
Microservices allow you do deploy, develop and debug in isolation, meaning that you don't rely on any other services to get your code into production. I have worked on a monolith before and making a small change had to go through a whole application test suite that took about 30 minutes, and would sometimes fail because someone in another team had just pushed some code in a different services and used a cheeky --no-verify... painful.
The most common patterns used to break down monoliths into microservices:
Domain based services (DDD)
Services structured around business sub-domains, i.e. a retailer that has sales might have a payments service, analytics service, promotion service.
Atomic transactional services
Each transaction has its own services. Transactions being operations between components that achieve a particular goal.
Business process based services
Splitting a system into services that before specific functions for business needs, e.g. appointments, payments, scheduling etc
How do you do it?
The Strangler pattern
The most common way of implementing one of these patterns is to gradulally replace services in the monolith with microservices. This is called the strangler pattern.
You start by identifying a service that you want to extract from the monolith. You then create a new microservice that implements the same functionality as the service in the monolith. You then gradually replace the functionality in the monolith with calls to the new microservice. Once you have replaced all the functionality in the monolith with calls to the new microservice, you can remove the service from the monolith.