0
0
Microservicessystem_design~12 mins

Why each service owns its data in Microservices - Architecture Impact

Choose your learning style9 modes available
System Overview - Why each service owns its data

This system shows a microservices architecture where each service manages its own database. This means no two services share the same data storage. The key goal is to keep services independent, scalable, and easy to maintain.

Each service owns its data to avoid tight coupling and to allow teams to work independently without conflicts.

Architecture Diagram
User
  |
  v
Load Balancer
  |
  v
API Gateway
  |
  +----------------+----------------+----------------+
  |                |                |
Service A       Service B        Service C
  |                |                |
Database A     Database B       Database C
  |                |                |
Cache A        Cache B          Cache C
Components
User
client
Sends requests to the system
Load Balancer
load_balancer
Distributes incoming requests evenly to API Gateway instances
API Gateway
api_gateway
Routes requests to appropriate microservices
Service A
service
Handles specific business logic and owns Database A
Service B
service
Handles different business logic and owns Database B
Service C
service
Handles another business domain and owns Database C
Database A
database
Stores data exclusively for Service A
Database B
database
Stores data exclusively for Service B
Database C
database
Stores data exclusively for Service C
Cache A
cache
Speeds up data access for Service A
Cache B
cache
Speeds up data access for Service B
Cache C
cache
Speeds up data access for Service C
Request Flow - 11 Hops
UserLoad Balancer
Load BalancerAPI Gateway
API GatewayService A
Service ACache A
Cache AService A
Service ADatabase A
Database AService A
Service ACache A
Service AAPI Gateway
API GatewayLoad Balancer
Load BalancerUser
Failure Scenario
Component Fails:Database A
Impact:Service A cannot write or read fresh data; cache may serve stale data
Mitigation:Use database replication for failover; cache serves stale reads; alert team for repair
Architecture Quiz - 3 Questions
Test your understanding
Why does each service have its own database?
ATo make the system slower
BTo keep services independent and avoid data conflicts
CTo share data easily between services
DTo reduce the number of databases
Design Principle
This architecture shows the principle of data ownership in microservices. Each service manages its own database to stay independent, avoid conflicts, and allow teams to develop and scale services separately. This reduces tight coupling and improves system resilience.