Architecture
Microservices
Backend
System Design
Engineering
Ask anything about this article
Hi! I've read this article.
What would you like to know?
@farhan
The pendulum has swung. After a decade of "microservices everything," major companies are moving back to monoliths. Here's what we've learned.
The problem: Data passing between services via S3 and SQS added latency and cost that exceeded the monitoring service's budget.
| Cost Category | Monolith | Microservices |
|---|---|---|
| Infrastructure | $ | $$ |
| Monitoring | $ | $$ |
| Debugging time | Hours | Days |
| Team overhead | 1 team | N teams |
| Network issues | None | Constant |
| Data consistency | Easy (transactions) | Hard (eventual consistency) |
| Deployment complexity | Low | High |
Traditional Monolith: Modular Monolith:
┌──────────────────┐ ┌──────────────────┐
│ Everything │ │ ┌────┐ ┌────┐ │
│ mixed │ │ │Auth│ │Users│ │
│ together │ → │ └──┬─┘ └──┬─┘ │
│ │ │ ┌──┴─┐ ┌──┴──┐ │
│ Spaghetti! │ │ │API │ │Orders│ │
│ │ │ └────┘ └─────┘ │
└──────────────────┘ └──────────────────┘
Clear boundaries,
single deployment
my-app/
├── modules/
│ ├── auth/ # Self-contained module
│ │ ├── routes.ts
│ │ ├── service.ts
│ │ ├── repository.ts
│ │ └── types.ts
│ ├── users/
│ │ ├── routes.ts
│ │ ├── service.ts
│ │ └── ...
│ └── orders/
│ └── ...
├── shared/ # Shared utilities
│ ├── database.ts
│ └── middleware.ts
└── app.ts # Composes modules
Ask these questions before choosing:
Start with a modular monolith. Extract services only when you have a proven need. The complexity cost of premature microservices far exceeds the refactoring cost of splitting a well-structured monolith later.
Architecture should solve problems, not create them.