Coarse-Grained Services

A microservices architecture introduces a lot of moving parts, and the initial costs will be higher. It’s often better to start with a few coarse-grained, self-contained services, and then decompose them into more fine-grained services as the application matures. With a new project, starting with a monolith or more coarse-grained services can enable us to initially bring a product to market more quickly today. Architects, developers, and operations are often more familiar with the approach, and the tools we use today have been created to work well with this method. As we bring the new application to market, we can further develop the skills necessary to managing a microservices architecture. The application boundaries will be much more stable and we can better understand where our boundaries should be.

If we do decide to start with something on the monolithic end of the spectrum, there are some considerations to take into account for approaching the design if we plan to transition to a microservices architecture. We could carefully design the application, while paying close attention to the modularity of the application to simplify the migration to microservices. This is great in theory, but in practice, maintaining modularity in a monolith can be challenging. It requires a lot of discipline to build a monolith in a way that it can easily be refactored into a microservices architecture.


Image Note

Data for each component of the monolith can be deployed to separate schemas in the same database or even separate databases. This can help enforce autonomy in the data store and ease the transition to a microservices architecture.


In some situations, there is absolutely nothing wrong with planning to build a monolith that gets us to market quickly, then replacing it with a microservices architecture and simply discarding the monolith. This requires some planning for how the monolith will eventually be displaced when the time comes.

Depending on the business and technical requirements, as well as the experience and knowledge of the team, we can start at or somewhere between a monolith and fine-grained microservices, as we see in Figure 3.1. Applications with requirements that have more to gain from microservices can start closer to the right on this graph, and teams with less experience can start closer to the left, with plans to further decompose as needed.

Image

FIGURE 3.1: Evolution of a monolith to a microservices architecture

A valid approach would be to start with fewer coarse-grained services and split them into more fine-grained services over time. We would still break the application up using the same principles and practices for service decomposition and design as we would when approaching a microservices architecture. We can then determine how ready we are with the operational aspects for microservices, and as the team’s experience, tools, and processes mature, we can move to finer-grained services. If we are struggling with only a few services, then managing a dozen is going to be painful.


Image Coarse-Grained Service Decomposition

When taking an approach to start with more coarse-grained services, use the principles and practices for service decomposition with a microservices architecture. Decompose services around business capability, not application layering.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.67.5