Ms Design Patterns
GitbookMicroservices2021-02-22
💡 Microservices: Design Pattern
📑 Microservies and Cloud Native
📑 Decomposition(分解) Patterns
- Decomposition of a system
-
Domain-based microservices
设计模式思路
- Domain-driven design
- Start with the model, not the datastore
- Evaluate (评估) actions
- Build the service, contract first
-
Business process-based microservices
- data domain, domains = microservices ?
- leverage
- Provide higher-level business functionality
- Allow you to encapsulate related domains
- No datasource access
- Distinct(不同) functional uses
-
Atomic transaction-based
- Guarantee atomicity, consistency, isolation, durability (ACID) transactions across domains
- Provide failure domains and rollbacks
- Force blocking until commit
- Don’t use distributed transactions
-
Strangler pattern (扼杀模式)
strangling a monolith (扼杀整体式), migrate, replace
- Sidecar pattern (边车模式)
📑 Integration Patterns
-
Gateway pattern
- provides a
facade
/proxy
, candecorate
,aggrregate
- Single layer that proxies, mutates (变异), or limits calls,
cors
- provides a
-
Process aggregator(聚合器) pattern ->
graphql
- Problem: You have several business processes that must be called together and have a composite payload
- Aggregator provides clients a single API to call
- Can introduce its own processing logic
- Can cause long blocking calls
- consolidated (综合的) model
-
Edge pattern
- Problem: Client use varies by platform and scaling a gateway presents wasted resources or clients need special business logic
- Client-specific “gateways""
- Focus on isolating calls for client systems
📑 Data Patterns
- Single service database
- Shared service database
-
Command Query Responsibility Segregation (命令查询职责隔离)
CQRS
- Multi-model bounded contexts (多模型有界上下文)
- Multi-interface operations, write versus read
- Divergence(发散) from simple CRUD
- examples: Eventual consitenency, Event-based models
-
Asynchronous eventing
- Event can cascade asynchronously from API
📑 ✋ Operation Patterns
- Log aggregation(聚合) patterns
-
Metrics aggregation patterns (指标汇总聚合模式)
- dashboard pattern
- Tracing patterns
- External configuration
- Service discovery
🤲🏻 Ancillary: 辅助的
- ms-nextjs
- ms-nestjs
- ms-file-services
- ms-gatsby
- ms-jamstack
- ms-subpub