Nov
20
2021

Microservices Design Patterns

microservices-design-patterns-img

Patterns are everywhere. It’s since decades. These are time tested proven methods to implement certain scenarios with testability, and follows other design principles. Microservices are evolved over the last decade to the much matured level now. Many patterns are evolved to suite various requirements.

Architecture Patterns

  • Layered Patterns
    • 2-tier
    • 3-tier
    • n-tier
  • Client-Server
    • A server and multiple clients
    • Most of the online applications such as email, banking apps, etc.
  • Separated Presentation
    • Model-View-Controller (MVC)
      • Model – contains core functionality and data
      • View – display information to the user
      • Controller – handles the input from the user
    • Model-View-Presentor (MVP)
      • The view is in charge like the controller in MVC
    • Model-View-ViewModel (MVVM or just ViewModel)
      • The ViewModel is the linking layer
    • Refer below diagram to understand differences between various presentation layers.application-architecture-pattern-separate-presentation
  • Microkernel Architecture
    • Also called pluggable architecture
    • Two components: a core system and plug-in modules
  • Service Oriented Architecture (SOA)
    • Application is divided into small independent services
    • May have single database
  • Microservice Architecture
    • Application is divided into micro independent services
    • Database per microservice
    • May be having separate UI service per microservice

 

Microservice Design Patterns

  • Decomposition Patterns
    • By business capabilities/function
    • By subdomain
    • Strangler Pattern
    • Sidecar Pattern/Service Mesh
    • By abstraction
    • Service per team
  • Data Management
    • Database per service
    • Shared database
    • CQRS (Command and Query Responsibility Segregation)
    • API Composition
    • Saga
    • Event Sourcing
  • Communication Patterns
    • Synchronous
    • Async – Event/Message based
    • Communication medium
      • RPC (Remote Procedure Call)
      • HTTP REST – XML/JSON
      • GraphQL
      • gRPC
  • Integration Patterns
    • API Gateway (External APIs)
    • Aggregator
    • Clientside UI composition
  • Deployment Patterns
    • Multiple service instances per host
    • One service instance per host
    • One service instance per VM
    • One service instance per container
    • Serverless
    • Blue Green
    • Canary
  • Corss cutting
    • Service Discovery
      • Client side
      • Server side
    • Service Registration
      • Self-registration
      • 3rd party registratioin
    • Circuit breaker
  • Observability
    • Log aggregation
    • Performance metrics
    • Distributed tracing
    • Health check

I think that’s comprehencive list of most of the important patterns related to microservices. However, the list will never be a complete list because some patterns are still evolving day-by-day as the usecases for microservices are also evolving. I will cover these patterns more in detail in future articles.