Microservices vs Monolith: The Honest Truth
“We need microservices because Netflix uses them.”
This sentence has killed more startups than bad product-market fit.
The Hidden Cost of Microservices#
You trade complexity of code for complexity of infrastructure.
- Network Latency: Function calls are nanoseconds. HTTP calls are milliseconds.
- Distributed Transactions: Rollbacks across 3 services are a nightmare (Requires Sagas pattern).
- Observability: Debugging a request that jumps through 5 containers requires expensive tracing tools (Jaeger/OpenTelemetry).
The Modular Monolith#
This is the sweet spot for 99% of companies. Keep code in one repo. Deploy as one binary. But enforce strict module boundaries.
# Django Example
/users
/payments
/inventoryIf payments imports from inventory, you have a violation. Enforce this via linters, not network boundaries.
When to Split?#
- Independent Scaling: Video processing needs 100 GPUs. The user login service needs 1 CPU.
- Team Scaling: You have 50 engineers. API collisions in git are slowing you down.