database per service pattern
Each service has its own private database; nothing else reads or writes those tables directly. Services communicate via APIs or events, never by SQL into another service's tables. Eliminates the shared-database coupling that turns microservices into a distributed monolith.
Each service has its own private database; nothing else reads or writes those tables directly. Services communicate via APIs or events, never by SQL into another service's tables. Eliminates the shared-database coupling that turns microservices into a distributed monolith.
symptoms
- changing one service's schema breaks an unrelated service
- reports requiring joins across service-owned tables
- services secretly reading each other's tables
causes
- shared database for "convenience"
- no enforcement of service boundaries at the persistence layer
fixes
- one DB / schema per service
- reporting via CDC + warehouse
- cross-service queries via API or events
you might say
- DB per service
- no cross-service queries