Definition
The basic concept of a microservice is simple—it’s a simple, standalone application that does one thing only and does that one thing well. The objective is to retain the simplicity, isolation, and productivity of the early app. A microservice cannot live alone; no microservice is an island—it is part of a larger system, running and working alongside other microservices to accomplish what would normally be handled by one large standalone application. – Hands-On Software Architecture with Golang
Definition
- Each microservice is:
- autonomous
- independent
- self-contained
- and individually deployable
- and scalable.
Concepts
-
Independent deployability
- criteria for this: make sure microservices are loosely coupled
- be able to change one service without having to change anything else
- criteria for this: make sure microservices are loosely coupled
-
Modeled around a business domain
- definition of service boundaries (see DDD)
-
Owning their own state
- hide internal state (same as encapsulation in OOP)
- clean delineation between internal implementation details and external contract
- be backward-compatible
- hide database that backs the service
- avoid DB showing
-
Size
“A microservice should be as big as my head” - James Lewis
- keep it to the size at which it can be easily understood
-
Flexibility
“Microservices buy you options” - James Lewis
- they have a cost and you must decide whether the cost is worth the options you want to take up
-
Alignment of architecture and organization
- Conway’s Law
- have team vertically organized
- same team owns front-end, business logic, data, back-end, security
- a so called stream-aligned team
- same team owns front-end, business logic, data, back-end, security
Advantages
- use the componentization strategy
- divide and rule more effectively
- with clear boundaries between components.
- create the right tool for each job in a microservice
- testability
- improved developer productivity and feature velocity.
Resources
Articles
- 2024-02-01 ◦ The False Dichotomy of Monolith vs. Microservices
- 2023-10-04 ◦ The Complete Microservices Guide - DEV Community
- 2022-12-15 ◦ Sam Newman: Practical Implications of Microservices in 14 Tips (old but still good)
- 2022-09-13 ◦ Event Storming to split Monolith into Microservices
- 2022-09-06 ◦ Common mistakes when splitting the monolith
- 2022-08-25 ◦ Design patterns for microservices - Azure Architecture Center | Microsoft Docs