HACKER Q&A
📣 martythemaniak

How Big Is a Microservice?


One thing that always frustrates me in technical discussions is that the things we talk about are never defined upfront. You can't have a meaningful discussion of Kubernetes use if one person says it's bad without mentioning they work on a 5 person team, while someone else says it's good because they work in a 100 person org.

Likewise, people argue monoliths vs microservices, but one person's idea could be microservice = 10,000loc monolith = 100,000loc, while the other person's idea is microservice < 100,000 loc, monolith = 1,000,000 loc. People could be disagreeing vehemently, yet agree without knowing that 100,000 loc is a good sized service.

So what is your definition?


  👤 ggeorgovassilis Accepted Answer ✓
Microservices is a deployment pattern, not a software architecture pattern. The size of a service is defined by the service's complexity which is bounded by the autonomy of the owning team. Higher autonomy allows for more complex services. Lower autonomy reduces the service complexity a team can handle and moves that complexity outside the service boundaries into the connecting system, increasing the need for inter-team coordination and governance.

👤 jdmichal
If you use domain-driven design, then microservices boundaries can be naturally drawn at domain boundaries and that will tend to work out pretty well. They should be as big as they need to be to support the domain.

I've definitely seen systems where the general gist was a microservice per data type, without any consideration of how those data types and the overarching domain were organized. And it turned out pretty terrible -- UI calls that were very coherent from a domain perspective blowing up into a chain of 3 or 4 calls to other services to get all the required data.

In reality, there was a primary data type with a few different types of supporting data. So a single microservice serving that primary data type along with the supporting data would have been quite appropriate.


👤 purpleblue
Just as big as it needs to be, and not more.