liveBook · Manning

Subdomain

As explained in Microservices Patterns, Second Edition

A coherent area of business responsibility within a larger domain.

A subdomain is a slice of business functionality within an application, typically owned by a small team. It organizes the code responsible for a coherent business area, rather than a technical role such as persistence or user interface. section 3.2.1 section 6.2.1

In the domain view, subdomains contain programming elements and can use one another. A system operation may start in one subdomain and collaborate with others. In an object-oriented application, a subdomain can contain classes organized into a package hierarchy. section 3.2.1

Creating an order

Order Management handles createOrder(), uses Consumer Management to verify that the consumer exists and can place orders, and uses Delivery Management to schedule delivery. Each subdomain has its own responsibility and business entities. section 3.2.1

A subdomain is not itself a deployable unit. A service contains one or more subdomains; a subdomain can also be a shared library used by multiple services. In a monolith, subdomains are packaged and deployed together. A layered monolith can scatter each subdomain’s code across web, domain, and persistence layers, creating a mismatch with team responsibilities. section 7.2.2 section 6.2.1

Consider subdomain characteristics when deciding how to package and deploy functionality:

  • Resource requirements: subdomains in the same service scale together, potentially overprovisioning resources for some of them. section 7.4.5
  • Business criticality and security: separating subdomains into services can isolate critical functionality or sensitive data. section 6.1.3
  • Regulations and domain-driven design type: subdomains can also differ in development regulations and in whether they are core, supporting, or generic. section 7.4.5

Scaling different workloads

Order Management needs ten instances, while GPU-based Fraud Detection needs only five. If both are packaged in one service, ten instances are provisioned together. Separate services allow each subdomain to scale independently and can reduce resource waste. section 7.4.5

Figure 7.7 Subdomains within the same service are scaled together, which can require over-provisioning of some resources. Putting them in separate services enables them to be scaled independently which improves resource utilization and reduces cost.
segregate by resources

Compare scaling subdomains together in one service with scaling them independently in separate services. section 7.4.5

Use subdomains to make business responsibilities and team ownership visible, then choose deployment boundaries based on concrete needs. Separate services can provide isolation and independent scaling, but a service may contain multiple subdomains; use the simplest architecture that addresses the actual problem. section 3.2.1 section 3.5 section 7.2.2

How Microservices Patterns, Second Edition covers it

How deep it goes
Defines subdomain structure and collaboration, then examines packaging, team alignment, isolation, and scaling decisions.
Examples
Uses order creation across three subdomains and contrasts scaling Order Management with GPU-based Fraud Detection.
What you can do after
Evaluate subdomain packaging and service separation against ownership, scaling, security, and business criticality.
How it connects
Connects subdomains to domain views, layered architecture, monoliths, microservices, and domain-driven design.

Also explained in

Compare how 4 books explain subdomain →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Microservices Patterns, Second Edition. The section links point to the parts of the book it draws on.