Turning the Modular Monolith into Microservices

Learn about refactoring a monolithic application into microservices by updating the initialization structure.

Our application, while it is modular, is a monolith. It is built as a single executable and can be deployed as a single application. There is nothing wrong with that, but faced with scaling issues, we have only one knob we can adjust. If we broke the application up by turning each module into its own microservice, then when faced with scaling issues, we would have finer control over how the application can be deployed to support the load.

Transitioning to microservices

Turning our application into microservices will have many steps, but will not be difficult:

  1. We will need to refactor the monolith construct used to initialize each module.

  2. We will make some small updates to the composition root of each module.

  3. We will then update each module so it can run as a standalone.

After we are done with these steps, we will update the Docker Compose file and make other small changes so that the two experiences, running the monolith or running the microservices, are the same.

Refactoring the monolith construct

Our motivation for updating this part of the application is so that we can continue to run the monolith after we have turned each module into a microservice:

Get hands-on with 1400+ tech skills courses.