Design Method & StylesChapter 14 · Split decisions
Microservices
Microservices
Microservices split an app into small services that each own one business area and its data, and that can each be released, scaled and fixed on their own. The price is that every call between them crosses the network — it's slower, it can fail, and each extra service a request has to wait on adds its own delay and its own chance of failure. Running many services also needs serious automation and monitoring. They pay off for large teams on a well-understood domain; for a small team or a young product they're mostly cost.
- Use when
- Many teams on a large, well-understood domain whose parts need separate releases, scaling or failure isolation · An organization that already has automated provisioning, deployment and monitoring
- Avoid when
- A small team or a young product whose boundaries are still moving — start with a (modular) monolith · Parts that call each other constantly or must change data together in one transaction · Without automation and monitoring in place — the services become a distributed monolith that is also hard to run
- Trade-offs
- Independent release, scaling and failure isolation, in exchange for network calls that are slower and can fail · Each synchronous hop adds latency and multiplies down availability; async messaging and breakers win some of it back · Each team owns its data, so changes across services lose one ACID transaction and need eventual consistency · Many pipelines, discovery, tracing and versioning to run — an operational premium paid before the benefits
- Requires
- Service boundaries, Circuit breaker, Async work with a queue
4 objectives · 5 misconceptions
- predict Predict how latency and availability change when one in-process checkout call becomes a chain of synchronous service calls — delays add per hop, availabilities multiply.
- explain Explain the operational prerequisites for microservices — fast provisioning, monitoring, automated deployment — and the premium a team pays before the benefits arrive.
- choose Choose between a (modular) monolith and microservices for a team from its size, how well the domain is understood and which parts truly need to release, scale or fail separately.
- explain Explain how timeouts, circuit breakers and moving work onto a queue keep one slow service from holding up every checkout.
- Not true: Splitting an app into microservices makes each request faster.
- Not true: A call to another service costs about the same as a function call.
- Not true: More services means higher availability, because one failing can't take the others down.
- Not true: You need microservices to handle a lot of traffic.
- Not true: Splitting into services by itself lets teams release independently.
Practice
No katas practise this yet.
Unlocks
Nothing yet.
Contrast with
No close look-alikes.