Article · Microservices · Modular Monolith
Microservices: independent deployments, real costs and when it pays off
The microservice style according to Lewis and Fowler, without the marketing: boundaries by business capability, own data, synchronous and asynchronous communication, resilience, prerequisites and the road from the monolith. Code in C#, TypeScript, Java, Go and Python.
Halina's pierogi place is now a chain: ten restaurants, catering, a mobile app and five teams. The payments team wants to deploy several times a day, the delivery team needs scaling on Friday evenings, and the weekly joint release of the modular monolith has become a bottleneck. This is the moment when microservices start to make sense – not because they're fashionable, but because team and deployment independence has become the problem.
- 2014
- the "Microservices" article – James Lewis and Martin Fowler describe the style and its 9 characteristics
- 1968
- Conway's law – a system's structure mirrors the organisation's communication structure
- 3
- prerequisites according to Fowler – rapid provisioning, basic monitoring, rapid deployment
Context and forces
- Team autonomy – every team wants to deploy its part without coordinating with four others.
- Different requirements – payments need auditing and isolation, delivery needs scaling, recommendations need Python and GPUs.
- Failure isolation – a bug in recommendations must not stop order intake.
- The cost of complexity – every service is a pipeline, monitoring, on-call duty and contracts.
In 1968, Melvin Conway observed that organisations design systems that mirror their communication structure. Microservices use this deliberately: service boundaries match team boundaries (the so-called inverse Conway manoeuvre), an idea developed in the book Team Topologies (2019).
Characteristics of the style
In 2014, James Lewis and Martin Fowler described nine common characteristics of microservice systems:
- Componentisation via services (deployed independently).
- Organised around business capabilities, not technical layers.
- Products, not projects – a team looks after a service for its whole life cycle.
- Smart endpoints and dumb pipes.
- Decentralised governance of technology.
- Decentralised data management – each service owns its data.
- Infrastructure automation.
- Design for failure.
- Evolutionary design.
Structure
| Element | Role | Watch out for |
|---|---|---|
| Service | One business capability, one team, independent deployment | too fine a split (nanoservices) |
| Own database | Only the service knows its schema; others use the API or events | cross-cutting reports need a separate model |
| API Gateway / BFF | A single entry point, routing, authentication, aggregation for the client | business logic in the gateway |
| Event broker | Asynchronous integration, load levelling | duplicates, ordering, contracts |
| Platform | CI/CD, containers, observability, secrets, service discovery | without it, every team builds all this itself |
What it looks like in code
Each service is a separate artifact with its own pipeline and database – even if they all live in one repository:
Repository structure in five stacks
pierogarnia/ ← monorepo, but every service builds and deploys on its own
├── services/
│ ├── Orders/ Orders.Api.csproj + OrdersDb (PostgreSQL) + Dockerfile + pipeline
│ ├── Kitchen/ Kitchen.Api.csproj + KitchenDb
│ ├── Delivery/ Delivery.Api.csproj + DeliveryDb
│ └── Payments/ Payments.Api.csproj + PaymentsDb
├── contracts/ Pierogarnia.Contracts (integration events, versioned NuGet package)
├── gateway/ YARP reverse proxy: /api/orders/** -> Orders, /api/delivery/** -> Delivery
└── aspire/ AppHost.cs: local orchestration of services, databases and Kafkapierogarnia/
├── orders-service/ Spring Boot 3, own schema, Flyway migrations, Dockerfile
├── kitchen-service/
├── delivery-service/
├── payments-service/
├── contracts/ Avro/JSON schemas published to a schema registry
└── gateway/ Spring Cloud Gateway routespierogarnia/ ← pnpm/Nx workspace, independent build targets
├── apps/
│ ├── orders/ NestJS app + Prisma schema (orders db)
│ ├── kitchen/
│ ├── delivery/
│ └── gateway/ BFF for the mobile app
└── libs/contracts/ zod schemas of integration events, versionedpierogarnia/
├── orders/ go.mod, cmd/orders/main.go, internal/..., migrations/
├── kitchen/
├── delivery/
├── payments/
└── proto/ gRPC contracts: payments/v1/payments.protopierogarnia/
├── orders/ FastAPI, SQLAlchemy, Alembic, pyproject.toml, Dockerfile
├── kitchen/
├── delivery/
├── payments/
└── contracts/ pydantic models of events, published as a packageThe rest of this article is for members
Create a free account or sign in to read it all. Still ahead:
- Trade-offs
- Prerequisites and the road from the monolith
- In practice
- Anti-patterns
- Related topics
- Test yourself