Reputation: 137
Microservices are normally designed according domains. These can become quite large even for smaller companies. But what about very big companies with a lot of smaller and bigger differences between their service offerings, e.g., due to legal requirements, local characteristics, size, etc.?
I see two alternatives:
My questions are:
Upvotes: 0
Views: 506
Reputation: 29877
It depends™.
To give an example of monoliths: Facebook uses a monolith and if I recall correctly if they had to build a deployment that used torrents to decentralice the download as it was +1GB. This is tens (or +100?) teams working on the same application. A common reason to use MS is to give teams full control of their apps and cut the amount of cross-team communication required. This is a fallacy, as a well architected solution (either monolith, MS or big services) will share the same characteristics: failure partition/isolation, domain boundaries, low cognitive load etc. I think it's important to mention this as many people struggle to build well architected monoliths, then try to the same with MS and end up with a distributed big ball of mud.
This is an opinion, but a well designed monolith is (usually) better than a microservice architecture (less moving parts, lower latency, considerable easier to refactor, etc). It's easier to start with a well designed monolith and move to microservices than the other way around, mainly because there's a big chance one is going to mess the initial microservice boundaries. Mary Poppendieck suggests the same in some of her presentations (maybe in The Future of Software Engineering?)
It's important to say that even if one builds a monolith, it doesn't mean that everything should be synchronous, and it's fine to use queues/topics or other integration approaches to communicate between the domains in the monolith. Most MS platforms I've seen are actually distributed monoliths. All services have to be deployed at the same time as they are not backwards/forwards compatible. This is the worse of both worls: a more complex architecture for little benefit.
I think your point about sync/async is the key regardless of a monolith or MS architecture. Everything that is not part of the critical path should be done asynchronously to partition errors and reduce latency.
A few more pointers:
Upvotes: 3
Reputation: 318
It depends on what you are trying to build.
In my opinion, if the application is small enough or is maintained by 2-3 people I would prefer a monolith due to lower latency, maintenance of the code is easier, and you have fewer things to worry about.
But for anything bigger than that you should consider MS, each part of the service can be maintained separately by different people, yes performance drops using MS but it can be optimized enough that the end user does not notice. If you are doing very heavy processing u can scale only that specific part of the service accordingly leaving the rest of the infra untouched.
And for your question about sync vs async as my general rule any service call that can be async should be async. And keep only the core functionality to break the chain of calls.
Upvotes: 1