- Published on
Monoliths vs Microservcies
- Authors
- Name
- John Duane
- @johnpduane
Is a microservice architecture a good choice for a given system?
It Depends
Kent Beck says, "any decent answer to an interesting question begins, 'it depends...'".
It Depends on Complexity
Martin Fowler writes, "my primary guideline would be don't even consider microservices unless you have a system that's too complex to manage as a monolith." Once a system reaches a certain base complexity, microservices improves productivity.
It Depends on Organizational Complexity
David Heinemeier Hansson argues its about team size saying microservices are, "an organizational pattern for dealing with intra-company communication at crazy scale when API calls beat scheduling coordination meetings."
There is a Happy Medium
Kelly Goetsch says, "It's not monolith vs. microservices. I think that's a false dichotomy. We can all agree that a giant monolith isn't very good, nor are thousands of little microservices. As with most of life, the truth lives somewhere in the pragmatic middle"
Microservice Pros and Cons
PROS
- Reduces data coupling (domain data models can evolve more easily)
- Reduces deployment coupling (teams can evolve part of the system without releasing everything)
- Reduces code coupling (e.g., teams can replace a Java implementation with a Node implementation without rearchitecting everything)
- Can improve vertical scaling (scale parts of the system independently)
CONS
- Adds deployment complexity (more things need QA, CI/CD, etc)
- Adds operational complexity (more things to monitor and maintain)
- Increases network calls which adds latency and complexity (i.e., monolith method calls become microservice network invocations)
My Take for E-commerce
E-commerce has high complexity - it's one of the reasons why Shopify, commercetools and related vendors exist. For the code we write for customers, the right thing is a service boundary for each major domain. At minimum, a BFF service makes sense to abstract the commerce engine from the front end to get the pros listed above. All other domains could be wrapped into a single service (e.g., monolith) depending on the complexity of the remaining requirements.