← All Concepts
Architecture

Microservices Architecture

An architectural pattern where an application is composed of small, independent services that communicate over well-defined APIs.

**Microservices** decompose a monolith into independently deployable services, each owning its own data and business logic. **Principles:** - **Single responsibility**: Each service does one thing well - **Independent deployment**: Deploy one service without affecting others - **Own data**: Each service has its own database - **API contracts**: Services communicate via well-defined APIs - **Decentralized governance**: Teams choose their own tech stack **Communication patterns:** - **Synchronous**: REST, gRPC (request-response) - **Asynchronous**: Message queues, event streaming (event-driven) **Challenges:** - Distributed transactions (Saga pattern) - Service discovery - Data consistency across services - Debugging across service boundaries (distributed tracing) - Network latency and failures **When to use monolith instead:** Early-stage products, small teams, simple domains.

Common Use Cases

  • Large-scale applications with many independent teams
  • Systems requiring independent scaling of components
  • Polyglot environments (different languages per service)
  • Frequent independent deployments

Advantages

  • +Independent deployment and scaling
  • +Technology flexibility per service
  • +Team autonomy and parallel development
  • +Fault isolation (one service failure doesn't crash all)

Disadvantages

  • -Distributed system complexity (network failures, latency)
  • -Data consistency challenges across services
  • -Operational overhead (monitoring, deployment, debugging)
  • -Over-engineering risk for small applications

Related Concepts

API GatewayMessage Queuesservice discovery