Polski

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.

By · · 11 min read

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:

  1. Componentisation via services (deployed independently).
  2. Organised around business capabilities, not technical layers.
  3. Products, not projects – a team looks after a service for its whole life cycle.
  4. Smart endpoints and dumb pipes.
  5. Decentralised governance of technology.
  6. Decentralised data management – each service owns its data.
  7. Infrastructure automation.
  8. Design for failure.
  9. Evolutionary design.

Structure

Diagram: Container view (C4 style): the pierogi chain as microservices
ElementRoleWatch out for
ServiceOne business capability, one team, independent deploymenttoo fine a split (nanoservices)
Own databaseOnly the service knows its schema; others use the API or eventscross-cutting reports need a separate model
API Gateway / BFFA single entry point, routing, authentication, aggregation for the clientbusiness logic in the gateway
Event brokerAsynchronous integration, load levellingduplicates, ordering, contracts
PlatformCI/CD, containers, observability, secrets, service discoverywithout 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

dotnet/repo-tree.txt
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 Kafka
java/repo-tree.txt
pierogarnia/
├── 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 routes
node/repo-tree.txt
pierogarnia/             ← 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, versioned
go/repo-tree.txt
pierogarnia/
├── orders/              go.mod, cmd/orders/main.go, internal/..., migrations/
├── kitchen/
├── delivery/
├── payments/
└── proto/               gRPC contracts: payments/v1/payments.proto
python/repo-tree.txt
pierogarnia/
├── orders/              FastAPI, SQLAlchemy, Alembic, pyproject.toml, Dockerfile
├── kitchen/
├── delivery/
├── payments/
└── contracts/           pydantic models of events, published as a package

The 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

Create a free account · Sign in