Why should each microservice have its own database?
So services can change schema, scale and deploy independently, and so no other team can couple to your tables. Shared databases turn into a distributed monolith: any change needs coordination. The cost is that cross-service transactions and joins no longer exist and must be rebuilt with patterns.
Answered in
Microservices Data Patterns: Database per Service, Saga, Outbox and CQRSOnce each service owns its data, transactions and queries break. Four patterns that put them back, with the failure each one prevents and the cost it adds.
Read the full analysisOther questions this article answers
More system design & architecture questions
- How much spare capacity should a gateway keep?
- Why are bounded queues important for availability?
- Should a load balancer always move requests away from an unhealthy server?
- Can a circuit breaker prevent every cascading failure?
- Why does pagination improve API performance beyond just 'smaller responses'?
- Why is asynchronous logging faster than writing logs synchronously?
- When does caching actually help API performance, and when doesn't it?
- Why does payload compression trade CPU time for network time, and when is that worth it?
Every answer on Crashtech is written by the editor of the article it comes from — never auto-summarised. Browse all answers or the System Design & Architecture beat.