Ms Design Patterns

GitbookMicroservices2021-02-22


💡 Microservices: Design Pattern

📑 Microservies and Cloud Native


📑 Decomposition(分解) Patterns


  • Decomposition of a system
  • Domain-based microservices

    设计模式思路

    1. Domain-driven design
    2. Start with the model, not the datastore
    3. Evaluate (评估) actions
    4. Build the service, contract first
    View Model
  • Business process-based microservices

    1. data domain, domains = microservices ?
    2. leverage
    3. Provide higher-level business functionality
    4. Allow you to encapsulate related domains
    5. No datasource access
    6. Distinct(不同) functional uses
    View Representation
  • Atomic transaction-based

    1. Guarantee atomicity, consistency, isolation, durability (ACID) transactions across domains
    2. Provide failure domains and rollbacks
    3. Force blocking until commit
    4. Don’t use distributed transactions
  • Strangler pattern (扼杀模式)

    strangling a monolith (扼杀整体式), migrate, replace

  • Sidecar pattern (边车模式)

📑 Integration Patterns


  • Gateway pattern

    1. provides a facade/proxy, can decorate, aggrregate
    2. Single layer that proxies, mutates (变异), or limits calls, cors
  • Process aggregator(聚合器) pattern -> graphql

    1. Problem: You have several business processes that must be called together and have a composite payload
    2. Aggregator provides clients a single API to call
    3. Can introduce its own processing logic
    4. Can cause long blocking calls
    5. consolidated (综合的) model
  • Edge pattern

    1. Problem: Client use varies by platform and scaling a gateway presents wasted resources or clients need special business logic
    2. Client-specific “gateways""
    3. Focus on isolating calls for client systems

📑 Data Patterns


  • Single service database
  • Shared service database
  • Command Query Responsibility Segregation (命令查询职责隔离)

    1. CQRS
    2. Multi-model bounded contexts (多模型有界上下文)
    3. Multi-interface operations, write versus read
    4. Divergence(发散) from simple CRUD
    5. examples: Eventual consitenency, Event-based models
  • Asynchronous eventing

    1. Event can cascade asynchronously from API

📑 ✋ Operation Patterns


  • Log aggregation(聚合) patterns
  • Metrics aggregation patterns (指标汇总聚合模式)

    1. dashboard pattern
  • Tracing patterns
  • External configuration
  • Service discovery

🤲🏻 Ancillary: 辅助的


  • ms-nextjs
  • ms-nestjs
  • ms-file-services
  • ms-gatsby
  • ms-jamstack
  • ms-subpub