The Adaptive Modular Monolith Concept
The Adaptive Modular Monolith describes an idea that lets you easily turn monolith modules into independent microservices via configuration
Join the DZone community and get the full member experience.
Join For FreeThe Modular Monolith architecture is reshaping how software systems are built and evolved. Although splitting modules into independent microservices typically requires significant efforts - such as repackaging, redeployment, and reconfiguration - an ideal architecture would allow modules to be spun off as independent services effortlessly, without these manual steps.
This capability distinguishes the Adaptive Modular Monolith concept from both traditional monoliths and microservices, providing a seamless, evolutionary path from simple development to scalable, flexible architectures on demand. It would enable starting with a unified, modular application and later extracting modules as standalone services with minimal overhead, combining the benefits of both monoliths and microservices in one system.
Modular Monolith
At its core, a Modular Monolith is a single deployable application composed of loosely coupled, clearly bounded modules that contain distinct business capabilities. You develop, test, and deploy the entire system as one unit, appreciating all the advantages of a monolith - streamlined builds, simplified CI/CD, and efficient in-memory communication.
Unlike classic monoliths that often suffer from tangled and entangled codebases, Modular Monoliths enforce strict boundaries, modular encapsulation, and explicit interfaces between components. This ensures that each module remains independent in logic, data, and responsibilities, even while running together.
This approach makes the Modular Monolith easier to disassemble to allow some modules to run independently. However, adopting different communication protocols, packaging, configuration, and deployment procedures, still requires significant manual effort. There's no automated procedure, even on development level, that allows conversion of some modules to independent microservices.
Adaptive Modular Monolith
What truly makes Adaptive Modular Monoliths stand out is the ability to spin off any module into an independent microservice simply by changing a configuration at runtime. So it would offer:
- No manual repackaging: You don’t have to rebuild or re-bundle modules into separate artifacts.
- No complex redeployment: Modules don’t require special deployment pipelines or containerization efforts for extraction.
- No code or interface changes: The same module code and APIs work whether inside the monolith or running standalone.
This can be made possible due to the following:
- Pluggable communication pipelines: The communication layer between modules is designed as pluggable and transparent pipelines. Inside the monolith, modules communicate via fast, in-memory direct boxed calls. When spun off, communication seamlessly switches to networked JSON-RPC or similar remote calls.
- Automatic module configuration: Each module registers itself with the core app, sharing its actual location and gathering the required configuration and locations of other modules it depends on. Thus, the only configuration needed for a spun-off module is the location of its core app; the rest is handled automatically.
- Single unit module deployment: All module code and their sole dependencies are packaged and deployed as single archives, similar to .war or .ear files, simplifying packaging and deployment.
- Automatic module deployment: There should be an automated deployment procedure to:
- Copy the necessary module code and dependencies to a new runtime (e.g., VM, node or container).
- Spin up the module as a container on-demand using scripts or orchestration tools like Docker and Kubernetes.
- Register the new service for discovery so the monolith routes calls transparently.
- Monitor and manage the spun-off service automatically.
Switching from monolith to independent service happens dynamically based on a configuration change - like flipping a switch. Even if it requires a restart - it provides significantly less efforts than diong that manually. This transparency preserves all API contracts and business logic unchanged.
Benefits of the Adaptive Modular Monolith
Using the Adaptive Modular Monolith offers several benefits:
- Rapid initial delivery: Build and deploy as a single unit quickly, avoiding the overhead of early, and possibly redundant, microservices adoption.
- Seamless scalability and isolation: Extract and scale modules independently later without costly redesigns, refactoring or disruptions.
- Operational simplicity: Manage a single deployable during development and gradually transition to distributed deployments on demand.
- Performance optimization: In-process calls may keep latency low until independence is necessary.
- Consistent behavior: Modules behave identically regardless of deployment mode, simplifying testing and troubleshooting.
How It Would Work in Practice
Imagine an application with modules for User Management, Orders, and Payments. Initially, all run together inside a Modular Monolith, communicating through direct method calls. As the system grows, the Payments module starts handling increased traffic requiring independent scaling.
Thanks to the pluggable communication layer, automatic configuration, and deployment, you just change a configuration flag - maybe restart the app - and the Payments module instantly begins running as a standalone service. No manual code changes, repackaging, or additional deployments are necessary beyond starting the Payments service. Your system evolves smoothly and safely.
Eventually, even automatic spin-offs can become possible - triggered by load statistics, for example.
Conclusion
The ability to effortlessly spin off modules from a Modular Monolith - without repackaging, redeployment, or code changes - is a groundbreaking architectural proposition. It combines everything good about monoliths with the flexibility and scalability of microservices - without the usual complexity and migration risks.
This approach enables teams to start simple, delivering value quickly, while retaining the choice to evolve their architecture freely as needs grow. Modular Monoliths with transparent, pluggable pipelines represent the next step in building adaptable, maintainable, and scalable software systems - where evolving from monolith to microservices is as easy as flipping a configuration switch.
Despite its immense potential, this approach remains largely unexplored and unimplemented in mainstream tools and frameworks, waiting to be embraced and brought to life. While, it definitely provides many technical difficulties, especially at deployment level, it would be beneficial to see even prof-of-concept implementation to start playing with. The Adaptive Modular Monolith is the future and stands out as the next frontier - an elegant, practical path toward future-proof systems that can scale easily without the usual complexity or risk.
Opinions expressed by DZone contributors are their own.
Comments