Nisan Coşkun

Quick Comparison of Microservices and Monolith Node.js

Published on December 27, 2019

Before we start I want to point out this comparison of Monoliths and Microservices should only be evaluated if you are using Nodejs as backend of your application.

The Good of Monolithic:

  • Simple to develop.
  • Simple to deploy. Especially if you are using ci/cd pipelines.

The Bad of Monolithic:

  • Hard to scale. Node.js event loop is single threaded. You can still use worker threads or child process for scaling through cpu(which is practically impossible if you working on mid-large size project).
  • Slow start-up time.
  • You must redeploy the entire application on each update.
  • Impact of a change is usually not very well understood which leads to unintentional bugs on parts of the project that you never worked on before. (this problem hits home for me. lol)
  • Monolithic applications has a barrier to adopting new technologies. Since changes in frameworks or languages will affect an entire application it is extremely expensive in both time and cost.

The Good of Microservices:

  • Relatively easy vertical & horizontal scaling.
  • Less complexity. New team members easily pick up how application works.
  • You can develop & deploy each service independently. This will relief main service from unwanted side effects of your change.
  • Easy to read logs(for understanding runtime bugs in production) since they are seperated from main service(this might be a biased argument).

The Bad of Microservices:

  • Microservices are frequently deployed on their own virtual machines/containers, causing a higher operational overhead.
  • Development will take more time compared to Monolith Architecture
  • Synchronizing and sharing data between Microservices is challenging and can be expensive if services needs to hold state.
  • Automation testing becomes difficult when each service component is running on a different runtime environment.

A lot of people suggest starting from the monolith first and switching to microservices later. That's wrong, if you are planing switching microservices later, don't start with monolith, because later it will be too much work and you are going to think it won't worth the time cost. Some people may think starting with microservices is overengineering(or premature optimization), that's true for lightweight projects but if you are devepoling a mid-large size project with node.js you have to overengineer some parts because node.js is so simple in design.

If you like it, share it!