Dark energy force: simple components
microservice architecture architecting dark energy and dark mattera dark energy, dark matter force
An application consists of one or more components (ie. executable or deployable units). Each component implements one or more subdomains.
Each component should be easy to understand and maintain. A component should have an easily understood structure and code base. It should also have easily understood runtime behavior. In particular, the requests that a component handles should be similar in nature, e.g. have similar resource requirements.
There are two ways to achieve this goal:
- Design modular components
- Design smaller components
Let’s look at each approach.
Design modular components
One way to achieve simplicity - or at least reduce unnecessary complexity - is modularity. Modularity is a fundamental software design principle. Software should consist of loosely (design-time) coupled elements each of which has a stable, well-defined interface.
A component should consist of loosely coupled subdomains rather than being organized around technical layers. A code base that is organized around subdomains is easier to understand and maintain. This is the approach taken by the Modular Monolith pattern.
One limitation, however, of modularity is that the component might still have a large number of dependencies. It might also handle a mixture of short-running requests and long-running batch jobs. Consequently, its runtime behavior might be difficult to understand and troubleshoot.
Design smaller components
When modularity fails to tame the complexity of a large component (e.g. monolith), the solution is to partition that component’s subdomains into multiple components, i.e. microservices. This ensures that each component is smaller, has fewer dependencies, and has simpler runtime behavior. It is, therefore, much easier to understand and maintain. You could consider this approach to be an application of the Single Responsibility Principle although the term ‘responsibility’ is somewhat imprecise.
Simple components acts as a repulsive force
The desire for simple components acts as a repulsive force that encourages you to package subdomains as separate components. It’s an anti-gravity between subdomains whose strength is proportional to the complexity of the two subdomains.