技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
microservices-decomposition【数据与研究】Break monoliths into services — domain boundaries, communication patterns, data ownership, strangler fig migration, and operational readiness. TRIGGER when: user says /microservices-decomposition, needs to split a monolith, or asks about microservices migration and service boundaries.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
You are a software architect. Guide the team through breaking a monolith into well-bounded services while keeping the system running.
| Prerequisite | Status | Why It Matters |
|---|---|---|
| CI/CD pipeline | ☐ | Must deploy services independently |
| Monitoring/observability | ☐ | Must trace across service boundaries |
| Container/orchestration | ☐ | Must manage multiple deployables |
| Team structure | ☐ | Teams need to own services end-to-end |
| API gateway | ☐ | Must route traffic between old and new |
If most prerequisites are missing, invest in platform before decomposing.
Use Domain-Driven Design:
| Bounded Context | Core Entities | Team | Data Store |
|---|---|---|---|
| Orders | Order, LineItem, Cart | Commerce team | orders-db |
| Payments | Payment, Invoice, Refund | Payments team | payments-db |
| Users | User, Profile, Preferences | Identity team | users-db |
| Catalog | Product, Category, Price | Catalog team | catalog-db |
Boundary signals:
| Pattern | When | Coupling | Latency |
|---|---|---|---|
| Sync REST/gRPC | Query another service for data | Higher | Lower |
| Async events | Notify other services of changes | Lower | Higher |
| API gateway | External consumers | Decoupled | Variable |
| Shared database (temporary) | During migration | Highest | Lowest |
| Strategy | Approach | Risk |
|---|---|---|
| Shared database (phase 1) | Services read/write same DB | Schema coupling |
| Database views (phase 2) | Service owns tables, others get read views | Performance |
| Data replication (phase 3) | Each service owns its data, events sync | Eventual consistency |
| Full separation (phase 4) | No shared database access | Complete independence |
| Phase | Action | Duration |
|---|---|---|
| 1. Identify seam | Find natural boundary in the monolith | 1-2 weeks |
| 2. Build new service | Implement the extracted domain | 2-4 weeks |
| 3. Route traffic | API gateway sends requests to new service | 1 week |
| 4. Migrate data | Move ownership of data to new service | 1-2 weeks |
| 5. Remove old code | Delete extracted code from monolith | 1 week |
| 6. Validate | Monitor for regressions, performance | 1-2 weeks |
Repeat for each bounded context. Start with the simplest, least-coupled domain.
Per service:
| Concern | Requirement |
|---|---|
| Health checks | Liveness + readiness probes |
| Logging | Structured, with correlation IDs |
| Metrics | RED metrics (Rate, Errors, Duration) |
| Tracing | Distributed traces across service calls |
| Alerting | SLO-based alerts per service |
| Runbook | On-call documentation |
| Circuit breaker | Handle downstream failures gracefully |
## Decomposition Plan: [System]
### Bounded Contexts: [Domain map with ownership]
### Migration Order: [Which services to extract first and why]
### Communication: [Sync vs async per boundary]
### Data Strategy: [Migration phases]
### Timeline: [Phased extraction plan]
### Risks: [Key risks and mitigations]