Microservice vs Monolith
View the key differences between Microservice based applications and Monolithic software architecture.
Guide Tasks
  • Read Tutorial

In the Spring of 2015 I sat in my chair at RailsConf in Atlanta, eagerly awaiting the keynote from David Heinemeier Hansson, the creator of the Rails framework and CEO of Basecamp. After hearing some of the features of the upcoming Rails 5 David went on to discuss the debate of Microservice vs Monolith. Before I get into what his thoughts were, let's review what a microservice is and what monolithic architecture is:

  • Microservice architecture - a group of applications that communicate with each other where each app performs a single, self-contained task.

  • Monolithic architecture - a monolith based system is a single application that contains all of the features of the system: front end, backend, and every feature.

So what does the creator of Rails consider is the best approach? David has never been one to mince words and very clearly intoned that he believed that monolithic based systems are the best approach. He mainly railed (ha, get it? Sorry) against client side MVC frameworks such as AngularJS and Ember. And for this argument I do tend to agree with him. I've never felt quite right with all of the workarounds necessary for integrating AngularJS into the Rails ecosystem, the code always feels a little dirty and it feels like I'm building two applications inside of one codebase.

However, even though I may not be a fan of integrating client side MVCs directly into a Rails application, I am a fan of the microservice based architecture, does that sound like a paradox, possibly, but let me explain my favorite approach. If you think of a real world example, what would a skilled carpenter use a miter saw for?

small

I think we can all agree that the saw has many purposes, but using it to polish dollhouse furniture wouldn't be a good idea. It technically would work, but it would require quite a bit of extra work and could lead to a slow and painful process.

medium

This is the way I like to think about software architecture decisions, I like to use the right tool for the right job. That is why I don't like the idea of integrating a client side MVC framework into a Rails application. However that doesn't mean that the entire concept of microservices are a bad idea. I think it makes perfect sense to build small, flexible applications that all work together to achieve the goal of a successful product.

So what is the right answer to the Microservice vs Monolith debate? It shouldn't come down to one being right and the other wrong, each application is unique which means that they should be approached differently. There are some cases were a microservice architecture makes the most sense, especially if the application needs to be able to scale well and if you have a large team of developers who can all focus on specific features. There also are many cases where a single, monolithic application is the best approach. Instead of thinking that you have to choose to be in the microservice or monolith camp of developers, simply analyze the requirements of the application and let the application's needs make the decision.

Lastly, here is a quote from Ayn Rand's, The Fountainhead that has always been a source of inspiration for me and is, what I believe, to be the right mindset that a developer should have when trying to make decisions on what type of architecture to use when building an application:

Rules? Here are my rules: what can be done with one substance must never be done with another. No two materials are alike. No two sites on earth are alike. No two buildings have the same purpose. The purpose, the site, the material determine the shape. Nothing can be reasonable or beautiful unless it’s made by one central idea, and the idea sets every detail. A building is alive, like a man. Its integrity is to follow its own truth, its one single theme, and to serve its own single purpose.