3 Designing microservices

 

This chapter covers

  • Principles of microservices design
  • Service decomposition by business capability
  • Service decomposition by subdomain

When we design a microservices platform, the first questions we face are, “How do you break down a system into microservices? How do you decide where a service ends and another one starts?” In other words, how do you define the boundaries between microservices? In this chapter, you’ll learn to answer these questions and how to evaluate the quality of a microservices architecture by applying a set of design principles.

The process of breaking down a system into microservices is called service decomposition. Service decomposition is a fundamental step in the design of our microservices since it helps us define applications with clear boundaries, well-defined scopes, and explicit responsibilities. A well-designed microservices architecture is essential to reduce the risk of a distributed monolith. In this chapter, you’ll learn two service decomposition strategies: decomposition by business capability and decomposition by subdomains. We’ll see how these methods work and use a practical example to learn to apply them. Before we delve into service decomposition strategies, we introduce the project that will guide our examples throughout this chapter and the rest of the book: CoffeeMesh.

3.1 Introducing CoffeeMesh

3.2 Microservices design principles

3.2.1 Database-per-service principle

3.2.2 Loose coupling principle

3.2.3 Single Responsibility Principle

3.3 Service decomposition by business capability

3.3.1 Analyzing the business structure of CoffeeMesh

3.3.2 Decomposing microservices by business capabilities

3.4 Service decomposition by subdomains

3.4.1 What is domain-driven design?

3.4.2 Applying strategic analysis to CoffeeMesh

3.5 Decomposition by business capability vs. decomposition by subdomain

Summary