What is the database per service pattern?
Answer
The database per service pattern is a core microservices principle stating that each service should own and manage its own database, and no other service should access that database directly. This ensures loose coupling — a service can change its database schema without breaking other services. Services expose their data only through their API. In practice, this means you might have PostgreSQL for the order service, MongoDB for the catalog service, and Redis for the session service — this mix is called polyglot persistence. The challenge is managing data consistency across service boundaries, which requires patterns like Sagas and event-driven synchronization rather than distributed transactions.
Previous
What is the difference between REST and gRPC in microservices?
Next
What role do containers (Docker) play in microservices?