Microservices and Service-Oriented Architecture
Split a system into independently deployable services and understand the real costs that come with it.
Advanced · about 6 hours · difficulty 4/5
Learn first: Monoliths and Modular Monoliths, gRPC and Protocol Buffers
Microservices decompose a system into small services, each owning one business capability and its own data, deployed independently and talking over the network. SOA (service-oriented architecture) is the older, enterprise-flavored ancestor, often built around a shared enterprise service bus and heavier contracts.
What you gain
- Teams deploy on their own schedule without coordinating a release train.
- Services scale independently (the image resizer can have 50 instances, the admin API 2).
- Failures and technology choices can be isolated.
What you pay
- Network calls fail: timeouts, retries and partial failure are now normal (see resilience patterns).
- Data is distributed: no joins across services and no simple transactions. You use events, sagas and eventual consistency.
- Operational overhead: many pipelines, dashboards, versions and on-call surfaces. Observability becomes mandatory.
- Contract management: breaking an API now breaks another team.
Design guidelines
- Split by business capability or bounded context, not by technical layer ("the database service" is an anti-pattern).
- Database per service: other services go through the API, never directly to your tables.
- Prefer asynchronous events for notifications between services and synchronous calls (REST, gRPC) only when an answer is needed now.
- An API gateway handles cross-cutting concerns (auth, rate limiting, routing) at the edge.
The distributed monolith
Services that must be deployed together, share a database, or call each other in long synchronous chains have all the costs of microservices and none of the benefits.
You are ready to move on when you can take a monolith's modules, argue which (if any) should become services, and describe how they would communicate and own data.
Key concepts
- Service boundaries by capability
- Database per service
- Sync vs async communication
- API gateway
- Service discovery
- Sagas for distributed workflows
- SOA and enterprise service bus
- Distributed monolith anti-pattern
Mini project
Extract one module (for example notifications) from your monolith into a separate service with its own database, communicating through an event queue, and document the failure modes you had to handle.
Check yourself
Two services share one database schema. Why does that undermine the main benefit of microservices?
Free resources
- Microservices (Martin Fowler)
- Microservice Architecture patterns (Chris Richardson)
- Microservices architecture style (Microsoft Learn)