Thursday, January 30, 2020

The Modular Monolith

Having been a micro-services sceptic from the start, and a proponent of the Monolith First approach, I've found Kamil Grzybek's Modular Monolith article series quite insightful:

Starting with a well designed and internally modularised monolith does seem to be the way to go. When architectural drivers change, like different modules evolving at different rates, it comes natural to split up the monolith into a few modules that are life-cycled and deployed independently, essentially creating micro-services. Scalability concerns in a module is another example of an architectural driver that often leads to such a split up.

You've got several tools at your disposal to keep your monolith properly modularised.

  • Designing proper module interfaces used by other parts of the system to interact with the module.
  • Use of Java packages to encapsulate modules, while keeping an eye on cyclomatic complexity.
  • The Java 9 module system. (Although I haven't used this myself yet.)
  • Smart use of multi-module builds in Maven. If you get this right, extracting a module to become its own micro-service might be a relatively trivial matter.
My basic advice would be: focussing on creating properly designed, modularised and high quality software first will make sure micro-services come easy later on.