Microservices Should Form a Polytree

https://news.ycombinator.com/rss Hits: 11
Summary

Microservices are a treacherous path. On paper, they look wonderful: small, focused components; independently deployable units; clean, well-defined interfaces. What could go wrong? Plenty. Teams often discover that a system that began as a tidy collection of services has quietly evolved into an Armageddon of impossible-to-trace failures and a painfully slow development experience. Microservices are easy to get wrong and a great way to cause infinite pain. They introduce complexity that has the unfortunate tendency to sneak up on you: you add a call here, expose a tiny API there, share a bit of logic “to stay DRY,” and before you know it, the whole thing is a mess. To avoid this situation in advance, I propose the following principle: microservices should form a polytree. This is an intentionally strict criterion. Simple enough to enable fast decision-making. The fact is that most teams do not have the time or appetite for endless architecture debates. They just need a straightforward check base for go/no-go decisions on. What is a polytree A polytree is a specific type of graph. Stated in precise terms, it's a directed acyclic graph whose underlying undirected graph is a tree. So, for example, this is a polytree: In order to check that this graph satisfies the definition of a polytree, notice that there are no directed cycles. Also the underlying undirected graph is connected and acyclic, i.e. a tree: What I mean by microservices should form a polytree is that the dependence structure between the services should be a polytree. So for example, in the case of the above graph, n1 may call n3, but n3 may not call n1. This rules out painful situations I'll highlight next. What is not a polytree For this post, it's important to highlight why a graph may fail to be a polytree, and to explain why excluding such structure is a good idea. Counterexample #1: A directed cycle One great way to mess up a microsevice architecture is to create a cyclical dependency structure such a...

First seen: 2025-12-12 16:46

Last seen: 2025-12-13 03:50