Published on

[draft] Monoliths & Microservices

Quotes

Kelsey Hightower profile image

Kelsey Hightower

Principal/Distinguished Engineer @ Google

Keith Adams profile image

Keith Adams

Principal Engineer @ Facebook/Slack

Jason Warner profile image

Jason Warner

Former CTO @ Github

Martin Fowler profile image

Martin Fowler

Thoughtworks

DHH profile image

DHH

Creator of Ruby on Rails

Nick Shrock profile image

Nick Shrock

Co-creator of GraphQL

Chris Richardson profile image

Chris Richardson

Author, Microservices Patterns

Sam Newman profile image

Sam Newman

Author, Monolith to Microservices

Overview

The extrordinary claim that the complicated computer program you have trouble developing and understanding needs to be a complicated distributed system instead and that will make it easier to deploy and change.
Keith Adams, Principal Architect at Facebook & Slack

Neither architecture is superior or perfect, companies are using both very effectively (and not-so-effectively) today. Facebook, Shopify and many others have served their massive and demanding audiences from monolithic applications, so the argument you must start using microservices to "scale" is likely a fallacy. In this article we explore some of the difficulties of adopting microservices.

"Another anti-pattern that I’ve observed is an organization making the adoption of microservices the goal"
Chris Richardson, Author, Microservices Patterns

You should have a clear goal in mind when adopting microservices, not just adopting the sake of following trends or as a way to mend "bad practices in your current application."

Complexity

These (microservices/distributed systems) are way way harder to work with than a single piece of software, than a single monolithic system.
Matt Ranney, Principal Architect at Uber & Doordash

When adopting microservices, you've now made you application a complex distributed systems, adding a very substantial layer of complexity to your system that shouldn't be overlooked and should be well thought out. It's very easy to overlook and minimize the problems introduced with distributing your application, e.g.

  • distributed transactions
  • rollbacks for distributed transactions
  • handling eventual consistency
  • network failures and partitions
  • event sourcing, cqrs
  • order of message delivery (fifo, lifo, no order guarantees, etc)
  • data consistency worker jobs
  • competing consumers
  • service discovery
  • dead-letter queues
  • idempotent consumers (at-most once delivery, at-least once delivery, etc)
  • reliable event delivery, e.g. outbox pattern
  • queue backpressure
  • infra complexity, e.g. review apps
  • supporting technologies, e.g. client libraries & maintenance
  • and many, many other difficulties

One argument you will likely hear during your career is that the application you've been building has become to large to develop and understand in a single codebase. This is likely an issue with your engineering practices/standards that is not just going to magically go away by distributing your system (and will likely become worse). Focusing your efforts towards improving those root issues and building a well modularized monolith will often pay dividends over adding another layer of complexity in your application and infrastructure. Remember, Facebook and Shopify operate primarily with monoliths — your system likely isn't as complex as you've proclaimed.

Scale

I’m willing to wager a monolith will outperform every microservice architecture. Just do the math on the network latency between each service and the amount of serialization and deserialization of each request. No contest.
Kelsey Hightower, Principal/Distinguished Engineer @ Google

Microservices are often touted as being "the way to scale," but this seems to be a bit overdrawn. Shopify handled black-friday traffic running on a monolith, it's very likely that you're organization can operate fine with a monolith. Shopify isn't the only company either — teams such as Facebook, StackOverflow and others have ran massive businesses on a monolith architecture. Putting more of your focus on effective caching mechanisms, improving data access operations and simple horizontal scaling can often have a larger payoff than just breaking up your application. You're organization is likely not dealing with the same scale issues as Netlix or Google, so you probably don't need the same solutions.

Organization structure

Organizational topology can arguably be the strongest rationale for adopting microserivces. If your organizations that have teams that operate truly indepedently and have almost zero cross-functional work, this can be the perfect fit for microservices. Google is a great example of this as their product offerings between Gmail, Search and Photos have very little overlap and are essentially autonomous organizations.

Microservices are best implemented when the organizational structure encourages it and can be viewed as more of a topological change, rather than a technical decision. I think of microservices as an organizational technology in a way. Moreso than a computer programming technology.
Keith Adams, Principal Architect at Facebook & Slack

Teams often turn to microservices as a way to simplify the code a team interacts with, but this often tends to add more complexity. Facebook runs in a monolith, allowing all developers to contribute to a single codebase that powers their entire application. The simplicity of this removes a large level of cognitive overhead.

microservices quote, nick

Co-Creator GraphQL, https://twitter.com/schrockn/status/1130567665548873728

Fault Isolation

Fault isolation is the idea that a failure in one part of the application won't bring down the entire system. In some languages, this can be a valid starting point for discussion. In languages like PHP, you get a sort of inherent fault isolation because of the architecture of PHP (all web requests get their own heap/stack). There are other potential solutions to this issue such as the "circuit breaker" technique or simply running those small pieces in isolated environments (e.g. lambda functions, etc.)

Hiring Talent

Monoliths are not inherently bad. Microservices are not inherently good. Microservices are not the goal. You don’t “win” by having microservices. Adopting a microservice architecture should be a conscious decision, one based on rational decision-making
Sam Newman, :quote: Monoliths are not inherently bad. Microservices are not inherently good. Microservices are not the goal. You don’t “win” by having microservices. Adopting a microservice architecture should be a conscious decision, one based on rational decision-making :author: Sam Newman :jobTitle:

Our industry struggles to attract enough talent to fill typical "software development engineer" roles. When you are looking to hiring microservices experts, the talent pool is drastically smaller than the pool of typical frontend & backend engineers. Once again, your team is not Netflix/Google/etc. so you probably don't have the seemingly endless capital (to offer $500k+ salaries) or the brand recognition to attract and retain these individuals.

Bottom Line

I'm convinced that one of the biggest architectural mistakes of the past decade was going full microservices.
Jason Warner, Former CTO of Github

Don't fall in the trap of adopting microservices to match the latest trends. Technology exists as a solution to a problem and microservices likely aren't the one solution to the issues you are, or think you are facing. Monoliths can be very "majestic" (David Heinemeier Hansson, creator of Ruby on Rails).

Monoliths are the future because the problem people are trying to solve with microservices doesn’t really line up with reality
Kelsey Hightower, Principal Architect at Google
microservices bike
The majority of software systems should be built as a single monolithic application. Do pay attention to good modularity within that monolith, but don't try to separate it into separate services.
Martin Fowler, ThoughtWorks