0
0
Microservicessystem_design~12 mins

When to use microservices (and when not to) - Architecture Diagram

Choose your learning style9 modes available
System Overview - When to use microservices (and when not to)

This system explains when to choose microservices architecture versus when to avoid it. Microservices break a large application into smaller, independent services that communicate over a network. The key requirements are scalability, independent deployment, and fault isolation for complex systems. However, for simple or small applications, microservices may add unnecessary complexity.

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
user
End user interacting with the system
Load Balancer
load_balancer
Distributes incoming requests evenly across API Gateway instances
API Gateway
api_gateway
Routes requests to appropriate microservices and handles authentication
Service A
microservice
Handles a specific business capability independently
Service B
microservice
Handles another distinct business capability independently
Service C
microservice
Handles a third business capability independently
Database A
database
Stores data for Service A
Database B
database
Stores data for Service B
Database C
database
Stores data 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 - 10 Hops
UserLoad Balancer
Load BalancerAPI Gateway
API GatewayService A
Service ACache A
Cache AService A
Service ADatabase A
Database AService A
Service AAPI Gateway
API GatewayLoad Balancer
Load BalancerUser
Failure Scenario
Component Fails:Database B
Impact:Service B cannot read or write data, causing failures in that business capability. Other services remain unaffected.
Mitigation:Use database replication and failover to a standby database. Service B can serve stale data from cache if available. Alerting and retries help recover.
Architecture Quiz - 3 Questions
Test your understanding
Which component directs user requests to the correct microservice?
ALoad Balancer
BAPI Gateway
CCache
DDatabase
Design Principle
This architecture shows how microservices enable independent scaling and fault isolation by splitting a system into smaller services with dedicated databases and caches. It also highlights the importance of API Gateway and Load Balancer for routing and load distribution. Microservices add complexity, so they are best for complex systems, not simple ones.