Microservices

Decompose application into small, independent services.

“Do one thing and do it well.”

Distributed Systems.

graph TD
    User -->|API Gateway| S1[Service A]
    User -->|API Gateway| S2[Service B]
    S1 -.->|RPC/Event| S2
    S1 --> DB1[(DB A)]
    S2 --> DB2[(DB B)]

When to use

  • Scalability: Need to scale parts independently.
  • Large Teams: Independent deployment pipelines.
  • Polyglot: Use different languages for different problems.

Explanation

Small autonomous services that work together. Each has its own DB.

Pros and Cons

Pros Cons
  • Scalability
  • Complexity (Distributed System Fallacies)
  • Autonomy
  • Data Consistency (CAP Theorem)
  • Code example

    Conceptual