Monolith or Microservices: Which should you start with?
Tuesday, January 16, 2018 at 8:56AM
HighScalability Team in microservices

 

This is a guest Post by Jake Lumetta, Founder and CEO, ButterCMS, an API-first CMS. For more content like this, follow @ButterCMS on Twitter and subscribe to our blog.

Conventional wisdom for startups counsels starting with a monolith, but are there situations where you should start with microservices instead? Interviews with dozens of CTOs illuminated the key considerations when deciding whether to start with a monolith or microservices.

Challenging Conventional Wisdom

My good friend Darby Frey recently kicked off a greenfield project after assuming his new role as Sr. Platform Engineering Lead of Gamut. Despite starting out with monolith at his previous company Belly, he discovered that — in the right circumstances — starting with a monolith isn’t always the best way to go.

“As one does, I allowed much of my thinking in my early days [at my new company] to be influenced by my previous company,” Darby told me.

At Belly, Darby and his team broke down their monolith into a fairly large microservices architecture. They managed to get it to a good place, but only after months of trials and tribulations migrating to microservices.

With this experience fresh in his mind, he approached his new project at Gamut a bit more cautious of microservices.

“I was firmly a member of Team Monolith. [I thought] let’s build a single application and just pull things apart later if we start to feel pain,” he said.

While this was a greenfield project, Darby’s team was small, and he had aggressive timelines, so on the surface, a monolith seemed like the obvious choice.

“[But with this new project], I was anxious to not repeat the mistakes of the past.”

And with that, he found himself faced with a decision we all struggle with, should we start with a monolith or microservices and how do we decide?

Evaluating Pros and Cons

Facing A Monolith

A monolith isn’t a dated architecture that we need to leave in the past. In certain circumstances, a monolith is ideal. I spoke to Steven Czerwinski, Head of Engineering at Scaylr and former Google employee, to better understand this.

“Even though we had had these positive experiences of using microservices at Google, we [at Scaylr] went [for a monolith] route because having one monolithic server means less work for us as two engineers,” he explained.

Monolith Pros:

Monolith Cons:

Embracing Microservices

Sometimes, microservices are the best option for your team. Julien Lemoine, CTO at Algolia, at chimed in on this point:

“We have always started with a microservices approach. The main goal was to be able to use different technology to build our service, for two big reasons:

1) We want to use the best tool for each service. Our search API is highly optimized at the lowest level and C++ is the perfect language for that. That said, using C++ for everything is a waste of productivity, especially to build a dashboard!

2) The want the best talents and using only one technology would limit our options. This is why we have different languages in the company, Go is less perfect than C++ when you want to optimize everything at the millisecond level but is the perfect language when performance is still key (processing of logs where we process several terabytes of logs per day, using ruby or python would be a waste of CPU)”

If your team is prepared, starting with microservices is wise as it allows you to get used to the rhythm of developing in a microservice environment, right from the start.

Microservices Pros

Microservices Cons

Applying Pros and Cons to Your Startup

The decision-making experiences of CTOs provide an excellent set of things to consider when you are making the choice between a monolith and microservices:

Are You In Familiar Territory?

Darby and his team at Gamut were able to delve directly into Microservices because he had experience with eCommerce platforms, and his company had a wealth of knowledge concerning the needs and demands of their customers. If he was traveling down an unknown path on the other hand, a monolith may have actually been the safer option.

Similarly, often startups are born out of pains experienced at previous companies. In those scenarios sometimes it’s quite clear scaling is going to be a primary requirement, especially in infrastructure based services like cloud log management.

Is Your Team Prepared?

Does your team have experience with microservices? What if you quadruple the size of your team within the next year, are microservices ideal for that situation? Evaluating these dimensions of your team is crucial to the success of your project.

If your team is prepared, starting with microservices is wise as it allows you to get used to the rhythm of developing in a microservice environment, right from the start.

How’s Your Infrastructure?

In reality, you’re going to need cloud-based infrastructure to make microservices work for your project.

“[Previously], you would want to start with a monolith because you wanted to deploy one database server. The idea of having to set up a database server for every single microservice and then scale out was a mammoth task. Only a huge, tech-savvy organization could do that,”  David Strauss, CTO of Pantheon explained to me.  

“Whereas today with services like Google Cloud and Amazon AWS, you have many options for deploying tiny things without needing to own the persistence layer for each one.”

Evaluate The Business Risk

You may think microservices is the “right” way to go as a tech-savvy startup with high ambitions. But microservices pose a business risk. David Strauss explained:

“A lot of teams overbuild their project initially; everyone wants to think their startup will be the next unicorn and that they should, therefore, build everything with microservices or some other hyper-scalable infrastructure. But that's usually wrong, almost all the time,” he said.

One example of this from his early days at Pantheon was a system that was limited to a single VM. They thought it would be a month or two until they’d be forced to scale it. It ended up being over a year -- and they ended up scaling it a completely different way than they had anticipated.

He went on to say that, in these cases, the areas that you thought you needed to scale are probably not the parts that will need to scale first, and that results in misplaced effort even for the systems that will need to scale.

Survey Your Landscape

From the CTO interviews, it became clear that there are circumstances that lend themselves best to either a monolith or microservices.

When To Start With A Monolith

Here are some scenarios that indicate that you should start your next project using monolithic architecture.

When To Start With Microservices

Here are some scenarios that indicate that you should start your next project using microservices:

There is no one-size-fits-all answer to the monolith vs. microservices debate. By applying the above considerations, however, you should be able to make a decision that best suits your startup.

Article originally appeared on (http://highscalability.com/).
See website for complete article licensing information.