Skip to content
StackDecode
System Design
11. Microservices ArchitectureAnimated

Database per Service Pattern

Each service owns its database.

The idea

No other service touches it directly; they use the service API.

Watch it work

Press play, pause, or step through. Some animations have settings you can change.

ClientAPI gatewayUsersOrdersPaymentsDBs
  • client
  • gateway / proxy
  • service
  • cache
  • data store
  • queue / stream

Clients call one entry point.

step:
1/4
at:
Client
1/8

The green dot is a request moving through the system.

Step by step

  1. 1Assign a database to each service
  2. 2Expose data only through APIs
  3. 3Sync with events if needed
  4. 4Scale each store independently

Where it is used

Loose coupling.

Watch out for

Cross-service queries and transactions get harder.

Related