From the course: Microservices: Design Patterns
Decomposition of a system
From the course: Microservices: Design Patterns
Decomposition of a system
- We have talked about microservices being smaller, but what does that really mean? Consider for a moment how you decompose a problem when writing a piece of software. You don't cram everything into a single function and then just finish. You break the problem into logical steps and convert those steps into reusable functions that can be used as the code base grows. This is much the same with microservices, but instead of a single problem statement, you are looking at all of the problems across the system as a whole. The first area of decomposition we will talk about is the service types that you can create. These are designed to provide very specific uses across the system as a whole. Each service has a distinct function in the system, and through building these services, we decompose the problems that we need to solve into smaller blocks of work. Domain-based services are usually one of the first areas we attack when building microservices. We will discuss how we use domain-driven design to build functional domains and then break up our system on these domain boundaries. Another breaking point in service designs come from your business processes themselves. Sometimes complex processes have so much inherent coupling that you cannot further break them down into smaller domains while still maintaining sustainable traffic patterns across your system. Because of the needs of network health, these business process domains become a clear point of delineation within your system without further breaking them down. Now, in some business models, eventual consistency isn't an acceptable model. Well, these are few and far between for most industries, however, there are some use cases for this, especially in areas like the financial services realm. As such, business processes themselves may be too broad to still achieve an atomic state, so you need to build your decomposition model around the atomic transaction itself. Functional use patterns are an important point that we will dig into some, but we need to talk about ways to achieve this in a microservices architecture. The first one that we will discuss is a very powerful strategy to migrate from a monolithic system into a microservices architecture. And this is called the strangler pattern. It is by far the most common pattern talked about when dealing with microservices because often, we are breaking down monoliths instead of writing new systems. Another strategy that we will discuss that often gets used to promote separation of concerns across the system is the sidecar pattern. This pattern allows us to offload many operational functions into separate components that they themselves get deployed alongside the main service component so that we don't litter our code with all of these functional needs across the system. So now that we have an overview of decomposition patterns, let's jump into our domain-based services.