@umacloud/knowledge 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/00-governance/governance-capabilities.md +557 -0
- package/00-governance/knowledge-map.md +39 -0
- package/00-governance/maintenance-policy.md +76 -0
- package/00-governance/review-checklist.md +81 -0
- package/README.md +13 -0
- package/ai/01-standards/agent-development-complete.md +691 -0
- package/ai/01-standards/llm-application-complete.md +488 -0
- package/ai/01-standards/mlops-complete.md +798 -0
- package/ai/01-standards/prompt-engineering-complete.md +646 -0
- package/ai/01-standards/rag-architecture-complete.md +649 -0
- package/ai/02-playbooks/llm-evaluation-playbook.md +847 -0
- package/ai/03-checklists/ai-project-checklist.md +215 -0
- package/ai/04-antipatterns/ai-antipatterns.md +661 -0
- package/ai/05-cases/case-rag-production.md +147 -0
- package/ai/06-glossary/ai-glossary.md +162 -0
- package/ai/agent-evaluation-benchmark.md +53 -0
- package/ai/ai-agent-memory-context-management.md +41 -0
- package/ai/ai-cost-capacity-optimization-playbook.md +42 -0
- package/ai/ai-data-security-and-compliance-playbook.md +37 -0
- package/ai/ai-domain-index-and-checklist.md +40 -0
- package/ai/ai-governance-maturity-model.md +50 -0
- package/ai/ai-model-selection-and-routing-strategy.md +47 -0
- package/ai/ai-observability-and-oncall-runbook.md +52 -0
- package/ai/ai-rag-engineering-playbook.md +42 -0
- package/ai/ai-red-team-and-safety-evaluation.md +42 -0
- package/ai/ai-release-readiness-and-rollback-gate.md +42 -0
- package/ai/llm-agent-engineering-deep-dive.md +57 -0
- package/ai/prompt-and-tool-guardrails.md +52 -0
- package/api/01-standards/enterprise-api-standards.md +198 -0
- package/api/01-standards/rest-api-design-guide.md +63 -0
- package/api/02-playbooks/api-pagination-playbook.md +93 -0
- package/api/02-playbooks/graphql-production-playbook.md +176 -0
- package/api/03-checklists/api-review-checklist.md +55 -0
- package/api/04-antipatterns/api-antipatterns.md +112 -0
- package/architecture/01-standards/api-gateway-patterns.md +496 -0
- package/architecture/01-standards/cloud-native-patterns.md +644 -0
- package/architecture/01-standards/distributed-systems-patterns.md +591 -0
- package/architecture/01-standards/event-driven-architecture.md +595 -0
- package/architecture/01-standards/microservices-patterns-complete.md +968 -0
- package/architecture/01-standards/microservices-patterns.md +495 -0
- package/architecture/01-standards/system-design-interview.md +664 -0
- package/architecture/02-playbooks/microservices-patterns-playbook.md +137 -0
- package/architecture/02-playbooks/migration-playbook.md +780 -0
- package/architecture/02-playbooks/system-design-playbook.md +779 -0
- package/architecture/03-checklists/architecture-decision-checklist.md +297 -0
- package/architecture/04-antipatterns/architecture-antipatterns.md +417 -0
- package/architecture/05-cases/case-netflix-microservices.md +413 -0
- package/architecture/06-glossary/architecture-glossary.md +164 -0
- package/architecture/adr-template-and-examples.md +38 -0
- package/architecture/api-gateway-deep-dive.md +1291 -0
- package/architecture/configuration-management.md +1162 -0
- package/architecture/distributed-transactions.md +1220 -0
- package/architecture/microservices-complete.md +735 -0
- package/architecture/resilience-and-disaster-patterns.md +37 -0
- package/architecture/service-governance.md +1198 -0
- package/architecture/system-architecture-deep-dive.md +37 -0
- package/backend/01-standards/analytics-and-growth.md +65 -0
- package/backend/01-standards/api-and-error-conventions.md +120 -0
- package/backend/01-standards/application-layering-and-packaging.md +160 -0
- package/backend/01-standards/auth-implementation.md +104 -0
- package/backend/01-standards/backend-framework-idioms.md +74 -0
- package/backend/01-standards/background-jobs-and-async.md +66 -0
- package/backend/01-standards/caching-strategies-complete.md +390 -0
- package/backend/01-standards/config-and-observability.md +77 -0
- package/backend/01-standards/data-modeling-and-persistence.md +94 -0
- package/backend/01-standards/django-complete.md +1765 -0
- package/backend/01-standards/email-and-notifications.md +64 -0
- package/backend/01-standards/fastapi-complete.md +925 -0
- package/backend/01-standards/file-upload-and-storage.md +66 -0
- package/backend/01-standards/graphql-api-complete.md +416 -0
- package/backend/01-standards/llm-application-standard.md +78 -0
- package/backend/01-standards/message-queue-patterns.md +379 -0
- package/backend/01-standards/microservices-and-distributed.md +78 -0
- package/backend/01-standards/nestjs-complete.md +2167 -0
- package/backend/01-standards/payment-integration.md +80 -0
- package/backend/01-standards/rate-limiting-complete.md +451 -0
- package/backend/01-standards/realtime-and-websocket.md +65 -0
- package/backend/01-standards/search-and-filtering.md +64 -0
- package/backend/01-standards/spring-boot-complete.md +445 -0
- package/backend/02-playbooks/api-design-playbook.md +718 -0
- package/backend/02-playbooks/email-send-playbook.md +130 -0
- package/backend/02-playbooks/file-upload-s3-playbook.md +153 -0
- package/backend/02-playbooks/typescript-enterprise-playbook.md +133 -0
- package/backend/02-playbooks/websocket-realtime-playbook.md +154 -0
- package/backend/03-checklists/api-launch-checklist.md +189 -0
- package/backend/04-antipatterns/backend-antipatterns.md +1051 -0
- package/blockchain/01-standards/blockchain-basics.md +557 -0
- package/blockchain/01-standards/smart-contract-development.md +1315 -0
- package/cicd/01-standards/deployment-and-delivery-standard.md +96 -0
- package/cicd/01-standards/github-actions-complete.md +473 -0
- package/cicd/01-standards/release-and-store-submission.md +75 -0
- package/cicd/02-playbooks/cicd-pipeline-playbook.md +144 -0
- package/cicd/02-playbooks/release-management-playbook.md +605 -0
- package/cicd/03-checklists/pipeline-security-checklist.md +168 -0
- package/cicd/04-antipatterns/cicd-antipatterns.md +589 -0
- package/cicd/05-cases/case-deployment-automation.md +221 -0
- package/cicd/05-cases/case-gitops-transformation.md +212 -0
- package/cicd/06-glossary/cicd-glossary.md +114 -0
- package/cicd/cicd-blueprint-deep-dive.md +38 -0
- package/cicd/release-readiness-gate.md +37 -0
- package/cloud-native/01-standards/container-security.md +741 -0
- package/cloud-native/01-standards/kubernetes-complete.md +812 -0
- package/cloud-native/02-playbooks/api-gateway-playbook.md +155 -0
- package/cloud-native/02-playbooks/gitops-with-argocd.md +760 -0
- package/cloud-native/02-playbooks/k8s-troubleshooting-playbook.md +1942 -0
- package/cloud-native/02-playbooks/message-queue-playbook.md +129 -0
- package/cloud-native/02-playbooks/multicloud-governance.md +726 -0
- package/cloud-native/02-playbooks/serverless-patterns.md +788 -0
- package/cloud-native/02-playbooks/service-mesh-playbook.md +612 -0
- package/cloud-native/02-playbooks/terraform-iac-playbook.md +143 -0
- package/cloud-native/03-checklists/container-security-checklist.md +431 -0
- package/cloud-native/03-checklists/k8s-production-readiness-checklist.md +460 -0
- package/cloud-native/04-antipatterns/container-antipatterns.md +660 -0
- package/cloud-native/04-antipatterns/k8s-antipatterns.md +743 -0
- package/cloud-native/05-cases/case-k8s-migration.md +478 -0
- package/cloud-native/05-cases/case-k8s-scaling.md +642 -0
- package/cloud-native/05-cases/case-k8s-security-incident.md +397 -0
- package/cloud-native/06-glossary/cloud-native-glossary.md +337 -0
- package/cross-platform/01-standards/cross-platform-frameworks.md +83 -0
- package/cross-platform/01-standards/platform-selection-and-architecture.md +77 -0
- package/data/01-standards/elasticsearch-complete.md +2098 -0
- package/data/01-standards/postgresql-complete.md +1613 -0
- package/data/01-standards/redis-complete.md +1527 -0
- package/data/02-playbooks/database-optimization-playbook.md +403 -0
- package/data/02-playbooks/elasticsearch-production-playbook.md +132 -0
- package/data/03-checklists/database-launch-checklist.md +187 -0
- package/data/04-antipatterns/database-antipatterns.md +873 -0
- package/data/05-cases/case-database-migration.md +310 -0
- package/data/06-glossary/database-glossary.md +440 -0
- package/data/data-governance-and-modeling-deep-dive.md +39 -0
- package/data-engineering/01-standards/airflow-complete.md +523 -0
- package/data-engineering/01-standards/kafka-complete.md +1521 -0
- package/data-engineering/02-playbooks/spark-etl-playbook.md +496 -0
- package/data-engineering/03-checklists/pipeline-launch-checklist.md +194 -0
- package/data-engineering/04-antipatterns/data-pipeline-antipatterns.md +684 -0
- package/data-engineering/05-cases/case-real-time-pipeline.md +355 -0
- package/data-engineering/06-glossary/data-engineering-glossary.md +429 -0
- package/database/01-standards/database-schema-standards.md +147 -0
- package/database/02-playbooks/postgresql-optimization-quick.md +52 -0
- package/database/02-playbooks/postgresql-performance-optimization.md +58 -0
- package/database/02-playbooks/postgresql-production-playbook.md +146 -0
- package/database/02-playbooks/redis-caching-playbook.md +117 -0
- package/database/03-checklists/database-review-checklist.md +50 -0
- package/database/04-antipatterns/database-antipatterns.md +112 -0
- package/design/01-standards/ui-design-system-complete.md +423 -0
- package/design/02-playbooks/design-handoff-playbook.md +254 -0
- package/design/02-playbooks/design-review-playbook.md +388 -0
- package/design/03-checklists/design-review-checklist.md +246 -0
- package/design/04-antipatterns/design-antipatterns.md +378 -0
- package/design/05-cases/case-design-system-adoption.md +328 -0
- package/design/06-glossary/design-glossary.md +329 -0
- package/design/ui-full-lifecycle-cross-platform-playbook.md +571 -0
- package/design/ux-system-deep-dive.md +38 -0
- package/design-systems/00-craft-rules.md +71 -0
- package/design-systems/aesthetic-families.md +43 -0
- package/design-systems/anti-ai-slop.md +162 -0
- package/design-systems/bold-geometric.md +120 -0
- package/design-systems/brutalist-bold.md +103 -0
- package/design-systems/editorial-clean.md +109 -0
- package/design-systems/glass-aurora.md +108 -0
- package/design-systems/modern-minimal.md +145 -0
- package/design-systems/premium-luxury.md +106 -0
- package/design-systems/product-type-design-map.md +48 -0
- package/design-systems/soft-warm.md +123 -0
- package/design-systems/tech-utility.md +113 -0
- package/desktop/01-standards/desktop-app-standard.md +72 -0
- package/desktop/01-standards/desktop-design.md +71 -0
- package/development/00-governance/document-template.md +41 -0
- package/development/01-standards/api-versioning-strategies.md +432 -0
- package/development/01-standards/authentication-patterns-complete.md +479 -0
- package/development/01-standards/css-architecture-complete.md +550 -0
- package/development/01-standards/database-migration-strategies.md +484 -0
- package/development/01-standards/elasticsearch-complete.md +347 -0
- package/development/01-standards/git-complete.md +371 -0
- package/development/01-standards/golang-complete.md +1565 -0
- package/development/01-standards/graphql-complete.md +298 -0
- package/development/01-standards/javascript-bundlers-complete.md +469 -0
- package/development/01-standards/javascript-typescript-complete.md +528 -0
- package/development/01-standards/jest-complete.md +275 -0
- package/development/01-standards/linux-complete.md +234 -0
- package/development/01-standards/logging-observability-complete.md +526 -0
- package/development/01-standards/microservices-communication.md +502 -0
- package/development/01-standards/mongodb-complete.md +406 -0
- package/development/01-standards/oauth2-complete.md +285 -0
- package/development/01-standards/performance-optimization-complete.md +289 -0
- package/development/01-standards/playwright-complete.md +247 -0
- package/development/01-standards/postgresql-complete.md +456 -0
- package/development/01-standards/pytest-complete.md +340 -0
- package/development/01-standards/python-async-programming.md +902 -0
- package/development/01-standards/python-complete.md +956 -0
- package/development/01-standards/python-decorators-complete.md +799 -0
- package/development/01-standards/python-design-patterns.md +2854 -0
- package/development/01-standards/python-packaging-distribution.md +420 -0
- package/development/01-standards/python-testing-strategies.md +607 -0
- package/development/01-standards/python-web-frameworks-comparison.md +471 -0
- package/development/01-standards/redis-complete.md +317 -0
- package/development/01-standards/rest-api-complete.md +316 -0
- package/development/01-standards/rust-complete.md +578 -0
- package/development/01-standards/typescript-advanced-types.md +1513 -0
- package/development/01-standards/web-security-complete.md +292 -0
- package/development/02-playbooks/api-design-playbook.md +810 -0
- package/development/02-playbooks/database-migration-playbook.md +580 -0
- package/development/02-playbooks/debugging-playbook.md +692 -0
- package/development/02-playbooks/feature-delivery-playbook.md +430 -0
- package/development/02-playbooks/incident-hotfix-playbook.md +387 -0
- package/development/02-playbooks/performance-optimization-playbook.md +531 -0
- package/development/02-playbooks/performance-tuning-playbook.md +652 -0
- package/development/02-playbooks/refactor-playbook.md +403 -0
- package/development/02-playbooks/release-playbook.md +469 -0
- package/development/03-checklists/architecture-review-checklist.md +168 -0
- package/development/03-checklists/data-migration-checklist.md +157 -0
- package/development/03-checklists/oncall-handover-checklist.md +173 -0
- package/development/03-checklists/pr-checklist.md +158 -0
- package/development/03-checklists/production-readiness-checklist.md +190 -0
- package/development/03-checklists/release-readiness-checklist.md +154 -0
- package/development/03-checklists/security-review-checklist.md +182 -0
- package/development/04-antipatterns/api-antipatterns.md +657 -0
- package/development/04-antipatterns/architecture-antipatterns.md +686 -0
- package/development/04-antipatterns/backend-antipatterns.md +648 -0
- package/development/04-antipatterns/cicd-antipatterns.md +540 -0
- package/development/04-antipatterns/code-smell-antipatterns.md +571 -0
- package/development/04-antipatterns/data-antipatterns.md +658 -0
- package/development/04-antipatterns/database-antipatterns.md +578 -0
- package/development/04-antipatterns/frontend-antipatterns.md +635 -0
- package/development/04-antipatterns/reliability-antipatterns.md +700 -0
- package/development/04-antipatterns/security-antipatterns.md +747 -0
- package/development/05-cases/case-api-version-migration.md +428 -0
- package/development/05-cases/case-authorization-hardening.md +383 -0
- package/development/05-cases/case-bluegreen-rollback.md +466 -0
- package/development/05-cases/case-cache-snowball-protection.md +485 -0
- package/development/05-cases/case-ci-cd-pipeline.md +544 -0
- package/development/05-cases/case-database-scaling.md +500 -0
- package/development/05-cases/case-db-hotspot-optimization.md +487 -0
- package/development/05-cases/case-incident-mttr-reduction.md +563 -0
- package/development/05-cases/case-microservice-migration.md +375 -0
- package/development/05-cases/case-performance-optimization.md +406 -0
- package/development/05-cases/case-security-incident-response.md +345 -0
- package/development/06-glossary/full-stack-glossary.md +166 -0
- package/development/09-maturity/quarterly-audit-template.md +35 -0
- package/development/11-ui-excellence/ui-aesthetic-system.md +41 -0
- package/development/11-ui-excellence/ui-engineering-excellence.md +435 -0
- package/development/12-scenarios/development-scenarios-guide.md +565 -0
- package/development/13-implementation-assets/implementation-toolkit.md +282 -0
- package/development/13-implementation-assets/knowledge-gates-execution.md +43 -0
- package/development/14-full-lifecycle/software-lifecycle-gates.md +511 -0
- package/development/15-lifecycle-templates/project-templates-collection.md +791 -0
- package/development/api-contract-and-versioning-guide.md +36 -0
- package/development/api-governance-complete.md +43 -0
- package/development/backend-engineering-complete.md +43 -0
- package/development/code-review-quality-complete.md +43 -0
- package/development/concurrency-reliability-complete.md +43 -0
- package/development/database-engineering-complete.md +43 -0
- package/development/engineering-effectiveness-complete.md +43 -0
- package/development/engineering-standards-deep-dive.md +38 -0
- package/development/frontend-engineering-complete.md +43 -0
- package/development/performance-capacity-complete.md +43 -0
- package/development/refactor-migration-complete.md +42 -0
- package/development/refactoring-and-techdebt-playbook.md +37 -0
- package/development/security-in-development-complete.md +43 -0
- package/devops/01-standards/cicd-pipeline-complete.md +262 -0
- package/devops/01-standards/docker-complete.md +1490 -0
- package/devops/01-standards/github-actions-complete.md +337 -0
- package/devops/01-standards/kubernetes-complete.md +638 -0
- package/devops/01-standards/terraform-complete.md +2117 -0
- package/devops/02-playbooks/docker-compose-playbook.md +233 -0
- package/devops/02-playbooks/docker-k8s-production-playbook.md +186 -0
- package/devops/02-playbooks/docker-production-playbook.md +952 -0
- package/edge-iot/01-standards/edge-iot-complete.md +473 -0
- package/experts/architect/api-design.md +178 -0
- package/experts/architect/methodology.md +124 -0
- package/experts/architect/security.md +75 -0
- package/experts/backend-lead/methodology.md +216 -0
- package/experts/devops/methodology.md +160 -0
- package/experts/frontend-lead/methodology.md +178 -0
- package/experts/product-manager/industry/ecommerce.md +43 -0
- package/experts/product-manager/industry/saas.md +40 -0
- package/experts/product-manager/methodology.md +97 -0
- package/experts/qa-lead/methodology.md +123 -0
- package/experts/qa-lead/test-strategy.md +128 -0
- package/experts/uiux-designer/methodology.md +125 -0
- package/frontend/01-standards/accessibility-complete.md +532 -0
- package/frontend/01-standards/accessibility-standard.md +74 -0
- package/frontend/01-standards/admin-dashboard-and-crud.md +72 -0
- package/frontend/01-standards/design-tokens-complete.md +444 -0
- package/frontend/01-standards/forms-and-validation.md +77 -0
- package/frontend/01-standards/frontend-architecture-and-layering.md +119 -0
- package/frontend/01-standards/i18n-and-localization.md +65 -0
- package/frontend/01-standards/nextjs-complete.md +451 -0
- package/frontend/01-standards/react-complete.md +713 -0
- package/frontend/01-standards/react-hooks-complete-guide.md +1100 -0
- package/frontend/01-standards/react-hooks-complete.md +1171 -0
- package/frontend/01-standards/seo-and-web-vitals.md +77 -0
- package/frontend/01-standards/state-management-complete.md +444 -0
- package/frontend/01-standards/vue-complete.md +499 -0
- package/frontend/01-standards/vue3-complete.md +2002 -0
- package/frontend/01-standards/web-framework-best-practices.md +64 -0
- package/frontend/01-standards/web-performance-complete.md +495 -0
- package/frontend/02-playbooks/accessibility-a11y-playbook.md +161 -0
- package/frontend/02-playbooks/frontend-performance-playbook.md +707 -0
- package/frontend/02-playbooks/i18n-internationalization-playbook.md +120 -0
- package/frontend/02-playbooks/performance-optimization-playbook.md +163 -0
- package/frontend/02-playbooks/react-nextjs-production-playbook.md +167 -0
- package/frontend/02-playbooks/react-state-management-playbook.md +173 -0
- package/frontend/03-checklists/component-quality-checklist.md +166 -0
- package/frontend/03-checklists/frontend-launch-checklist.md +299 -0
- package/frontend/04-antipatterns/frontend-antipatterns.md +886 -0
- package/frontend/05-cases/case-performance-optimization.md +274 -0
- package/harmony/01-standards/harmonyos-arkts-standard.md +75 -0
- package/harmony/01-standards/harmonyos-design.md +65 -0
- package/high-quality-engineering-playbook.md +54 -0
- package/incident/01-standards/incident-response-complete.md +303 -0
- package/incident/02-playbooks/chaos-engineering-playbook.md +883 -0
- package/incident/02-playbooks/postmortem-playbook.md +398 -0
- package/incident/03-checklists/incident-readiness-checklist.md +181 -0
- package/incident/04-antipatterns/incident-antipatterns.md +490 -0
- package/incident/05-cases/case-cascade-failure.md +176 -0
- package/incident/06-glossary/incident-glossary.md +114 -0
- package/incident/postmortem-and-response-deep-dive.md +39 -0
- package/industries/ecommerce/ecommerce-complete.md +631 -0
- package/industries/education/education-complete.md +555 -0
- package/industries/fintech/fintech-complete.md +501 -0
- package/industries/gaming/gaming-complete.md +587 -0
- package/industries/healthcare/healthcare-complete.md +452 -0
- package/low-code/01-standards/low-code-complete.md +944 -0
- package/miniprogram/01-standards/ai-common-mistakes.md +61 -0
- package/miniprogram/01-standards/miniprogram-custom-navbar-capsule.md +77 -0
- package/miniprogram/01-standards/miniprogram-design.md +61 -0
- package/miniprogram/01-standards/miniprogram-standard.md +81 -0
- package/mobile/01-standards/android-material-design.md +70 -0
- package/mobile/01-standards/flutter-complete.md +384 -0
- package/mobile/01-standards/ios-design-hig.md +78 -0
- package/mobile/01-standards/mobile-app-standard.md +85 -0
- package/mobile/01-standards/react-native-complete.md +352 -0
- package/mobile/02-playbooks/mobile-cross-platform-playbook.md +175 -0
- package/mobile/02-playbooks/mobile-performance.md +473 -0
- package/mobile/03-checklists/mobile-release-checklist.md +234 -0
- package/mobile/04-antipatterns/mobile-antipatterns.md +798 -0
- package/mobile/05-cases/case-app-performance.md +500 -0
- package/mobile/05-cases/case-app-startup-optimization.md +218 -0
- package/mobile/06-glossary/mobile-glossary.md +484 -0
- package/observability/01-standards/observability-standards.md +103 -0
- package/observability/02-playbooks/prometheus-grafana-playbook.md +135 -0
- package/observability/02-playbooks/structured-logging-playbook.md +73 -0
- package/observability/03-checklists/observability-checklist.md +54 -0
- package/observability/04-antipatterns/observability-antipatterns.md +106 -0
- package/operations/01-standards/prometheus-monitoring-complete.md +1578 -0
- package/operations/02-playbooks/capacity-planning-playbook.md +620 -0
- package/operations/03-checklists/production-launch-checklist.md +365 -0
- package/operations/04-antipatterns/operations-antipatterns.md +664 -0
- package/operations/05-cases/case-sre-practices.md +581 -0
- package/operations/06-glossary/operations-glossary.md +120 -0
- package/operations/aiops-anomaly-detection.md +758 -0
- package/operations/capacity-planning.md +1061 -0
- package/operations/chaos-engineering.md +659 -0
- package/operations/incident-command-system.md +38 -0
- package/operations/observability-complete.md +442 -0
- package/operations/slo-sli-playbook.md +517 -0
- package/operations/sre-operations-deep-dive.md +39 -0
- package/package.json +8 -0
- package/performance/01-standards/performance-and-scalability.md +80 -0
- package/performance/01-standards/performance-standards.md +156 -0
- package/performance/02-playbooks/query-optimization-playbook.md +103 -0
- package/performance/03-checklists/performance-checklist.md +56 -0
- package/performance/04-antipatterns/performance-antipatterns.md +146 -0
- package/product/01-standards/product-management-complete.md +285 -0
- package/product/02-playbooks/feature-launch-playbook.md +207 -0
- package/product/02-playbooks/user-research-playbook.md +532 -0
- package/product/03-checklists/feature-launch-checklist.md +275 -0
- package/product/04-antipatterns/product-antipatterns.md +355 -0
- package/product/05-cases/case-mvp-to-scale.md +384 -0
- package/product/06-glossary/product-glossary.md +462 -0
- package/product/feature-prioritization-framework.md +40 -0
- package/product/kpi-and-metric-tree.md +37 -0
- package/product/product-discovery-and-prd-deep-dive.md +41 -0
- package/quantum/01-standards/quantum-complete.md +1186 -0
- package/security/01-standards/api-security-complete.md +511 -0
- package/security/01-standards/container-runtime-security.md +574 -0
- package/security/01-standards/data-protection-gdpr.md +543 -0
- package/security/01-standards/owasp-top10-complete.md +1890 -0
- package/security/01-standards/secure-coding-baseline.md +90 -0
- package/security/01-standards/supply-chain-security.md +441 -0
- package/security/01-standards/web-security-checklist.md +108 -0
- package/security/01-standards/zero-trust-architecture.md +521 -0
- package/security/02-playbooks/auth-sso-playbook.md +166 -0
- package/security/02-playbooks/incident-response-security-playbook.md +588 -0
- package/security/02-playbooks/owasp-api-security-playbook.md +129 -0
- package/security/02-playbooks/payment-integration-playbook.md +119 -0
- package/security/02-playbooks/penetration-testing-playbook.md +517 -0
- package/security/03-checklists/security-audit-checklist.md +356 -0
- package/security/04-antipatterns/security-coding-antipatterns.md +580 -0
- package/security/05-cases/case-log4shell-incident.md +537 -0
- package/security/05-cases/case-major-breaches.md +468 -0
- package/security/06-glossary/security-glossary.md +212 -0
- package/security/compliance-automation.md +993 -0
- package/security/container-security.md +680 -0
- package/security/devsecops-complete.md +426 -0
- package/security/sast-dast-sca.md +775 -0
- package/security/secrets-management.md +594 -0
- package/security/security-architecture-deep-dive.md +37 -0
- package/security/threat-modeling-stride-playbook.md +40 -0
- package/seed-templates/auth-system.md +59 -0
- package/seed-templates/blog-content.md +94 -0
- package/seed-templates/dashboard.md +89 -0
- package/seed-templates/docs-site.md +73 -0
- package/seed-templates/e-commerce.md +50 -0
- package/seed-templates/saas-landing.md +92 -0
- package/seed-templates/settings-page.md +51 -0
- package/testing/01-standards/test-strategy-and-layering.md +83 -0
- package/testing/01-standards/testing-strategy-complete.md +422 -0
- package/testing/01-standards/unit-testing-best-practices.md +118 -0
- package/testing/02-playbooks/e2e-testing-playbook.md +988 -0
- package/testing/02-playbooks/testing-strategy-playbook.md +126 -0
- package/testing/03-checklists/test-strategy-checklist.md +208 -0
- package/testing/04-antipatterns/testing-antipatterns.md +718 -0
- package/testing/05-cases/case-testing-transformation.md +300 -0
- package/testing/06-glossary/testing-glossary.md +110 -0
- package/testing/risk-based-test-matrix.md +36 -0
- package/testing/testing-strategy-deep-dive.md +37 -0
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: message-queue-patterns
|
|
3
|
+
title: 消息队列模式完整指南
|
|
4
|
+
domain: backend
|
|
5
|
+
category: 01-standards
|
|
6
|
+
difficulty: intermediate
|
|
7
|
+
tags: [backend, kafka, message, patterns, queue, rabbitmq, redis, streams]
|
|
8
|
+
quality_score: 70
|
|
9
|
+
last_updated: 2026-06-15
|
|
10
|
+
---
|
|
11
|
+
# 消息队列模式完整指南
|
|
12
|
+
|
|
13
|
+
## 概述
|
|
14
|
+
|
|
15
|
+
消息队列是分布式系统的核心基础设施,实现服务解耦、异步处理、流量削峰和事件驱动架构。本指南覆盖 Kafka、RabbitMQ 和 Redis Streams 的选型、核心模式和最佳实践。
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 方案选型对比
|
|
20
|
+
|
|
21
|
+
| 特性 | Kafka | RabbitMQ | Redis Streams |
|
|
22
|
+
|------|-------|----------|---------------|
|
|
23
|
+
| 定位 | 分布式事件流平台 | 消息代理 | 轻量级消息流 |
|
|
24
|
+
| 吞吐量 | 百万级/秒 | 万级/秒 | 十万级/秒 |
|
|
25
|
+
| 消息持久化 | 磁盘,可配置保留期 | 内存+磁盘 | 内存+RDB/AOF |
|
|
26
|
+
| 消费模型 | Consumer Group + Offset | Queue/Exchange 路由 | Consumer Group |
|
|
27
|
+
| 消息顺序 | Partition 内有序 | Queue 内有序 | Stream 内有序 |
|
|
28
|
+
| 延迟 | 毫秒级 | 微秒级 | 微秒级 |
|
|
29
|
+
| 适用场景 | 事件溯源/日志/大数据 | 任务队列/RPC/路由 | 轻量事件/缓存层流 |
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Kafka
|
|
34
|
+
|
|
35
|
+
### 核心概念
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
Producer -> Topic (Partition 0, 1, 2...) -> Consumer Group
|
|
39
|
+
├── Consumer A (Partition 0, 1)
|
|
40
|
+
└── Consumer B (Partition 2)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 生产者
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
from confluent_kafka import Producer
|
|
47
|
+
|
|
48
|
+
producer = Producer({
|
|
49
|
+
"bootstrap.servers": "kafka:9092",
|
|
50
|
+
"acks": "all", # 等待所有副本确认
|
|
51
|
+
"retries": 3,
|
|
52
|
+
"enable.idempotence": True, # 幂等生产者
|
|
53
|
+
"max.in.flight.requests.per.connection": 5,
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
def send_event(topic: str, key: str, value: dict):
|
|
57
|
+
import json
|
|
58
|
+
producer.produce(
|
|
59
|
+
topic=topic,
|
|
60
|
+
key=key.encode("utf-8"),
|
|
61
|
+
value=json.dumps(value).encode("utf-8"),
|
|
62
|
+
callback=delivery_report,
|
|
63
|
+
)
|
|
64
|
+
producer.flush()
|
|
65
|
+
|
|
66
|
+
def delivery_report(err, msg):
|
|
67
|
+
if err:
|
|
68
|
+
logger.error(f"Message delivery failed: {err}")
|
|
69
|
+
else:
|
|
70
|
+
logger.info(f"Message delivered to {msg.topic()} [{msg.partition()}]")
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 消费者
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
from confluent_kafka import Consumer, KafkaError
|
|
77
|
+
|
|
78
|
+
consumer = Consumer({
|
|
79
|
+
"bootstrap.servers": "kafka:9092",
|
|
80
|
+
"group.id": "order-service",
|
|
81
|
+
"auto.offset.reset": "earliest",
|
|
82
|
+
"enable.auto.commit": False, # 手动提交 offset
|
|
83
|
+
"max.poll.interval.ms": 300000,
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
consumer.subscribe(["order-events"])
|
|
87
|
+
|
|
88
|
+
try:
|
|
89
|
+
while True:
|
|
90
|
+
msg = consumer.poll(timeout=1.0)
|
|
91
|
+
if msg is None:
|
|
92
|
+
continue
|
|
93
|
+
if msg.error():
|
|
94
|
+
if msg.error().code() == KafkaError._PARTITION_EOF:
|
|
95
|
+
continue
|
|
96
|
+
raise KafkaException(msg.error())
|
|
97
|
+
|
|
98
|
+
try:
|
|
99
|
+
event = json.loads(msg.value().decode("utf-8"))
|
|
100
|
+
process_order_event(event)
|
|
101
|
+
consumer.commit(msg) # 处理成功后手动提交
|
|
102
|
+
except ProcessingError as e:
|
|
103
|
+
logger.error(f"Failed to process: {e}")
|
|
104
|
+
send_to_dlq(msg) # 发送到死信队列
|
|
105
|
+
consumer.commit(msg)
|
|
106
|
+
finally:
|
|
107
|
+
consumer.close()
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Kafka 最佳实践
|
|
111
|
+
|
|
112
|
+
- **分区数**: 通常等于消费者数量的倍数
|
|
113
|
+
- **Key 设计**: 使用业务 ID 保证同一实体的消息有序
|
|
114
|
+
- **保留策略**: 根据业务需求设置(7 天/30 天/永久)
|
|
115
|
+
- **压缩**: 使用 lz4 或 snappy 减少网络和存储开销
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## RabbitMQ
|
|
120
|
+
|
|
121
|
+
### Exchange 类型
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
Direct: routing_key 精确匹配
|
|
125
|
+
Fanout: 广播到所有绑定队列
|
|
126
|
+
Topic: routing_key 模式匹配 (*.error, order.#)
|
|
127
|
+
Headers: 基于 header 属性匹配
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### 生产者
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
import pika
|
|
134
|
+
import json
|
|
135
|
+
|
|
136
|
+
connection = pika.BlockingConnection(pika.ConnectionParameters(
|
|
137
|
+
host="rabbitmq",
|
|
138
|
+
credentials=pika.PlainCredentials("guest", "guest"),
|
|
139
|
+
heartbeat=600,
|
|
140
|
+
))
|
|
141
|
+
channel = connection.channel()
|
|
142
|
+
|
|
143
|
+
# 声明持久化队列和交换机
|
|
144
|
+
channel.exchange_declare(exchange="orders", exchange_type="topic", durable=True)
|
|
145
|
+
channel.queue_declare(queue="order-processing", durable=True)
|
|
146
|
+
channel.queue_bind(queue="order-processing", exchange="orders", routing_key="order.created")
|
|
147
|
+
|
|
148
|
+
def publish_order_event(order_id: str, event_type: str, data: dict):
|
|
149
|
+
channel.basic_publish(
|
|
150
|
+
exchange="orders",
|
|
151
|
+
routing_key=f"order.{event_type}",
|
|
152
|
+
body=json.dumps({"order_id": order_id, **data}),
|
|
153
|
+
properties=pika.BasicProperties(
|
|
154
|
+
delivery_mode=2, # 持久化消息
|
|
155
|
+
content_type="application/json",
|
|
156
|
+
message_id=str(uuid.uuid4()),
|
|
157
|
+
timestamp=int(time.time()),
|
|
158
|
+
),
|
|
159
|
+
)
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### 消费者
|
|
163
|
+
|
|
164
|
+
```python
|
|
165
|
+
def callback(ch, method, properties, body):
|
|
166
|
+
try:
|
|
167
|
+
event = json.loads(body)
|
|
168
|
+
process_order(event)
|
|
169
|
+
ch.basic_ack(delivery_tag=method.delivery_tag)
|
|
170
|
+
except Exception as e:
|
|
171
|
+
logger.error(f"Processing failed: {e}")
|
|
172
|
+
# 拒绝并重新入队(或发送到 DLQ)
|
|
173
|
+
ch.basic_nack(delivery_tag=method.delivery_tag, requeue=False)
|
|
174
|
+
|
|
175
|
+
channel.basic_qos(prefetch_count=10) # 流控
|
|
176
|
+
channel.basic_consume(queue="order-processing", on_message_callback=callback)
|
|
177
|
+
channel.start_consuming()
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### 死信队列 (DLQ)
|
|
181
|
+
|
|
182
|
+
```python
|
|
183
|
+
# 声明 DLQ
|
|
184
|
+
channel.queue_declare(queue="order-processing-dlq", durable=True)
|
|
185
|
+
|
|
186
|
+
# 主队列绑定 DLQ
|
|
187
|
+
channel.queue_declare(
|
|
188
|
+
queue="order-processing",
|
|
189
|
+
durable=True,
|
|
190
|
+
arguments={
|
|
191
|
+
"x-dead-letter-exchange": "",
|
|
192
|
+
"x-dead-letter-routing-key": "order-processing-dlq",
|
|
193
|
+
"x-message-ttl": 86400000, # 消息 TTL: 24h
|
|
194
|
+
"x-max-length": 100000, # 队列最大长度
|
|
195
|
+
},
|
|
196
|
+
)
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Redis Streams
|
|
202
|
+
|
|
203
|
+
### 基本操作
|
|
204
|
+
|
|
205
|
+
```python
|
|
206
|
+
import redis
|
|
207
|
+
|
|
208
|
+
r = redis.Redis(host="localhost", port=6379, decode_responses=True)
|
|
209
|
+
|
|
210
|
+
# 生产者:添加消息到 Stream
|
|
211
|
+
message_id = r.xadd("order-events", {
|
|
212
|
+
"order_id": "ORD-001",
|
|
213
|
+
"event": "created",
|
|
214
|
+
"amount": "99.99",
|
|
215
|
+
"timestamp": str(int(time.time())),
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
# 创建消费者组
|
|
219
|
+
r.xgroup_create("order-events", "order-service", id="0", mkstream=True)
|
|
220
|
+
|
|
221
|
+
# 消费者:读取消息
|
|
222
|
+
while True:
|
|
223
|
+
messages = r.xreadgroup(
|
|
224
|
+
groupname="order-service",
|
|
225
|
+
consumername="worker-1",
|
|
226
|
+
streams={"order-events": ">"},
|
|
227
|
+
count=10,
|
|
228
|
+
block=5000,
|
|
229
|
+
)
|
|
230
|
+
|
|
231
|
+
for stream, entries in messages:
|
|
232
|
+
for msg_id, fields in entries:
|
|
233
|
+
try:
|
|
234
|
+
process_event(fields)
|
|
235
|
+
r.xack("order-events", "order-service", msg_id)
|
|
236
|
+
except Exception as e:
|
|
237
|
+
logger.error(f"Failed: {e}")
|
|
238
|
+
# 消息留在 PEL 中,稍后重试
|
|
239
|
+
|
|
240
|
+
# 处理 pending 消息(故障恢复)
|
|
241
|
+
pending = r.xpending_range("order-events", "order-service", "-", "+", count=100)
|
|
242
|
+
for entry in pending:
|
|
243
|
+
if entry["time_since_delivered"] > 300000: # 超过 5 分钟未确认
|
|
244
|
+
messages = r.xclaim(
|
|
245
|
+
"order-events", "order-service", "worker-1",
|
|
246
|
+
min_idle_time=300000,
|
|
247
|
+
message_ids=[entry["message_id"]],
|
|
248
|
+
)
|
|
249
|
+
for msg_id, fields in messages:
|
|
250
|
+
reprocess_event(fields)
|
|
251
|
+
r.xack("order-events", "order-service", msg_id)
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
## 事件驱动架构模式
|
|
257
|
+
|
|
258
|
+
### 事件溯源 (Event Sourcing)
|
|
259
|
+
|
|
260
|
+
```python
|
|
261
|
+
# 事件存储
|
|
262
|
+
class EventStore:
|
|
263
|
+
def __init__(self, producer: KafkaProducer):
|
|
264
|
+
self.producer = producer
|
|
265
|
+
|
|
266
|
+
def append(self, aggregate_id: str, event: DomainEvent):
|
|
267
|
+
self.producer.send(
|
|
268
|
+
topic=f"events-{event.aggregate_type}",
|
|
269
|
+
key=aggregate_id,
|
|
270
|
+
value={
|
|
271
|
+
"event_id": str(uuid.uuid4()),
|
|
272
|
+
"aggregate_id": aggregate_id,
|
|
273
|
+
"event_type": event.__class__.__name__,
|
|
274
|
+
"data": event.to_dict(),
|
|
275
|
+
"version": event.version,
|
|
276
|
+
"timestamp": datetime.utcnow().isoformat(),
|
|
277
|
+
},
|
|
278
|
+
)
|
|
279
|
+
|
|
280
|
+
# 事件重放
|
|
281
|
+
class OrderAggregate:
|
|
282
|
+
def __init__(self):
|
|
283
|
+
self.status = None
|
|
284
|
+
self.items = []
|
|
285
|
+
self.total = 0
|
|
286
|
+
|
|
287
|
+
def apply(self, event: DomainEvent):
|
|
288
|
+
if isinstance(event, OrderCreated):
|
|
289
|
+
self.status = "created"
|
|
290
|
+
self.items = event.items
|
|
291
|
+
elif isinstance(event, OrderPaid):
|
|
292
|
+
self.status = "paid"
|
|
293
|
+
self.total = event.amount
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### 幂等消费者
|
|
297
|
+
|
|
298
|
+
```python
|
|
299
|
+
class IdempotentConsumer:
|
|
300
|
+
def __init__(self, redis_client: redis.Redis):
|
|
301
|
+
self.redis = redis_client
|
|
302
|
+
self.ttl = 86400 * 7 # 7 天去重窗口
|
|
303
|
+
|
|
304
|
+
def process(self, message_id: str, handler: Callable):
|
|
305
|
+
key = f"processed:{message_id}"
|
|
306
|
+
if self.redis.exists(key):
|
|
307
|
+
logger.info(f"Duplicate message {message_id}, skipping")
|
|
308
|
+
return
|
|
309
|
+
|
|
310
|
+
handler()
|
|
311
|
+
|
|
312
|
+
self.redis.set(key, "1", ex=self.ttl)
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### 重试策略
|
|
316
|
+
|
|
317
|
+
```python
|
|
318
|
+
import time
|
|
319
|
+
from functools import wraps
|
|
320
|
+
|
|
321
|
+
def retry_with_backoff(max_retries=3, base_delay=1.0, max_delay=60.0):
|
|
322
|
+
def decorator(func):
|
|
323
|
+
@wraps(func)
|
|
324
|
+
def wrapper(*args, **kwargs):
|
|
325
|
+
for attempt in range(max_retries + 1):
|
|
326
|
+
try:
|
|
327
|
+
return func(*args, **kwargs)
|
|
328
|
+
except RetryableError as e:
|
|
329
|
+
if attempt == max_retries:
|
|
330
|
+
raise
|
|
331
|
+
delay = min(base_delay * (2 ** attempt), max_delay)
|
|
332
|
+
jitter = delay * 0.1 * random.random()
|
|
333
|
+
time.sleep(delay + jitter)
|
|
334
|
+
logger.warning(f"Retry {attempt + 1}/{max_retries}: {e}")
|
|
335
|
+
return wrapper
|
|
336
|
+
return decorator
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
---
|
|
340
|
+
|
|
341
|
+
## 监控指标
|
|
342
|
+
|
|
343
|
+
| 指标 | 说明 | 告警阈值 |
|
|
344
|
+
|------|------|----------|
|
|
345
|
+
| Consumer Lag | 消费者落后的消息数 | > 10000 |
|
|
346
|
+
| Message Rate | 每秒消息产生/消费量 | 异常波动 |
|
|
347
|
+
| Error Rate | 处理失败率 | > 1% |
|
|
348
|
+
| DLQ Size | 死信队列堆积数 | > 100 |
|
|
349
|
+
| Processing Latency | 消息处理延迟 P99 | > 5s |
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
## 常见反模式
|
|
354
|
+
|
|
355
|
+
| 反模式 | 问题 | 正确做法 |
|
|
356
|
+
|--------|------|----------|
|
|
357
|
+
| 消息体过大 | 网络/存储开销 | 消息只传 ID + 元数据,数据走存储 |
|
|
358
|
+
| 不做幂等 | 重复处理 | 消息 ID 去重 + 幂等写入 |
|
|
359
|
+
| 自动提交 offset | 消息丢失 | 处理成功后手动提交 |
|
|
360
|
+
| 忽略 DLQ | 失败消息丢失 | 配置死信队列并监控 |
|
|
361
|
+
| 无重试策略 | 临时故障导致消息丢失 | 指数退避重试 |
|
|
362
|
+
| 强依赖消息顺序 | 扩展困难 | 仅在必要时保证分区内有序 |
|
|
363
|
+
|
|
364
|
+
---
|
|
365
|
+
|
|
366
|
+
## Agent Checklist
|
|
367
|
+
|
|
368
|
+
- [ ] 根据吞吐量和延迟需求选择合适的消息队列
|
|
369
|
+
- [ ] 生产者启用幂等写入和重试
|
|
370
|
+
- [ ] 消费者手动提交 offset/ack
|
|
371
|
+
- [ ] 实现幂等消费者(消息 ID 去重)
|
|
372
|
+
- [ ] 配置死信队列 (DLQ) 并监控大小
|
|
373
|
+
- [ ] 实现指数退避重试策略
|
|
374
|
+
- [ ] 消息体控制在 1MB 以内
|
|
375
|
+
- [ ] Kafka 分区 Key 设计保证业务有序性
|
|
376
|
+
- [ ] 消费者 Group 内消费者数 <= 分区数
|
|
377
|
+
- [ ] 监控 Consumer Lag / Error Rate / DLQ Size
|
|
378
|
+
- [ ] 消息 Schema 有版本管理(Avro/Protobuf + Schema Registry)
|
|
379
|
+
- [ ] 生产环境 Kafka 至少 3 副本,acks=all
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: microservices-and-distributed
|
|
3
|
+
title: 微服务与分布式系统标准(商业级 · 中大型)
|
|
4
|
+
domain: backend
|
|
5
|
+
category: 01-standards
|
|
6
|
+
difficulty: advanced
|
|
7
|
+
tags: [微服务, microservices, 分布式, 服务边界, grpc, 事件驱动, saga, api网关, 服务发现, 熔断, 分布式追踪, 最终一致, 商业级]
|
|
8
|
+
quality_score: 93
|
|
9
|
+
last_updated: 2026-06-19
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# 微服务与分布式系统标准(商业级 · 中大型)
|
|
13
|
+
|
|
14
|
+
> 微服务能独立扩展/部署,但引入分布式复杂度(一致性、网络故障、可观测)。**先模块化单体,复杂度真的需要时再拆**——不要一上来就微服务。本标准给出拆分与分布式要点。
|
|
15
|
+
|
|
16
|
+
## 1. 什么时候上微服务(先别)
|
|
17
|
+
|
|
18
|
+
- 默认 **模块化单体**(按 feature 分模块、边界清晰),它简单、易一致、好调试。
|
|
19
|
+
- 出现这些信号再考虑拆:团队/代码规模大需独立部署、不同模块负载/伸缩差异大、技术栈需异构、组织按域划分。
|
|
20
|
+
- "复杂度不够时不配拥有微服务"——过早微服务 = 分布式的痛 + 没有收益。
|
|
21
|
+
|
|
22
|
+
## 2. 服务边界(按业务域)
|
|
23
|
+
|
|
24
|
+
- 按 **DDD 限界上下文(Bounded Context)** 划分服务,不按技术层;一个服务拥有一块业务能力 + 自己的数据。
|
|
25
|
+
- **每个服务独占自己的数据库**,别共享库(共享库=隐式耦合,失去独立性)。服务间不直接读对方表。
|
|
26
|
+
- 边界要高内聚低耦合;避免"分布式单体"(拆了但互相强同步调用一改全改)。
|
|
27
|
+
|
|
28
|
+
## 3. 服务间通信
|
|
29
|
+
|
|
30
|
+
- **同步**(REST/gRPC):用于需即时响应的查询/命令;gRPC 适合内部高性能。注意级联故障。
|
|
31
|
+
- **异步**(消息/事件,Kafka/RabbitMQ/NATS):用于解耦、削峰、事件驱动;**幂等消费 + 至少一次投递**。
|
|
32
|
+
- 优先**事件驱动 + 最终一致**降低耦合;同步调用链尽量短。
|
|
33
|
+
- 契约管理:接口/事件 schema 版本化、向后兼容。
|
|
34
|
+
|
|
35
|
+
## 4. 数据一致性(分布式难点)
|
|
36
|
+
|
|
37
|
+
- 跨服务事务用 **Saga**(编排 orchestration 或协同 choreography)+ 补偿,而非分布式 2PC。
|
|
38
|
+
- **Outbox 模式**保证"业务写库 + 发事件"原子(同事务写 outbox,再投递)。
|
|
39
|
+
- 接受**最终一致**;关键不变量在单服务内强一致。
|
|
40
|
+
|
|
41
|
+
## 5. 弹性(网络一定会失败)
|
|
42
|
+
|
|
43
|
+
- 每个跨服务调用:**超时 + 重试(指数退避) + 熔断(circuit breaker) + 限流 + 舱壁隔离(bulkhead)**。
|
|
44
|
+
- 优雅降级:依赖挂了返回兜底/缓存,而非级联全崩。
|
|
45
|
+
- 幂等:重试安全。
|
|
46
|
+
|
|
47
|
+
## 6. 基础设施
|
|
48
|
+
|
|
49
|
+
- **API 网关**:统一入口、鉴权、限流、路由、聚合(BFF)。
|
|
50
|
+
- **服务发现** + 负载均衡;配置中心;密钥管理。
|
|
51
|
+
- 容器化 + 编排(k8s);每服务独立 CI/CD + 独立扩缩容。
|
|
52
|
+
|
|
53
|
+
## 7. 可观测(分布式必须)
|
|
54
|
+
|
|
55
|
+
- **分布式追踪**(OpenTelemetry):一次请求跨服务串联,定位慢/错在哪个服务。
|
|
56
|
+
- 集中日志(带 trace_id) + 指标(每服务 RED) + 告警。
|
|
57
|
+
- 健康检查 + 优雅停机。
|
|
58
|
+
|
|
59
|
+
## 8. 反模式(出现即不合格)
|
|
60
|
+
|
|
61
|
+
- 过早微服务(小项目硬拆);分布式单体(服务间强同步耦合、一改全改)。
|
|
62
|
+
- 多服务共享一个数据库;服务直接读对方表。
|
|
63
|
+
- 跨服务用 2PC;写库与发事件不原子(无 outbox)。
|
|
64
|
+
- 跨服务调用无超时/重试/熔断 → 级联雪崩。
|
|
65
|
+
- 无分布式追踪/集中日志,分布式问题无法定位。
|
|
66
|
+
|
|
67
|
+
## 9. 最低交付 checklist
|
|
68
|
+
|
|
69
|
+
- [ ] 默认模块化单体;确有需要才按 DDD 限界上下文拆服务。
|
|
70
|
+
- [ ] 每服务独占数据库,不共享/不直读对方表;边界高内聚低耦合。
|
|
71
|
+
- [ ] 通信选型(同步 REST/gRPC + 异步事件),事件幂等消费;契约版本化。
|
|
72
|
+
- [ ] 跨服务一致性用 Saga + Outbox + 最终一致,不用 2PC。
|
|
73
|
+
- [ ] 每个跨服务调用 超时+重试+熔断+限流+降级。
|
|
74
|
+
- [ ] API 网关 + 服务发现 + 配置/密钥中心 + 独立 CI/CD/扩缩容。
|
|
75
|
+
- [ ] 分布式追踪(OpenTelemetry) + 集中日志(trace_id) + 每服务指标告警。
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
**参考**:DDD 限界上下文、微服务模式(martinfowler.com/microservices)、Saga/Outbox、Circuit Breaker、API Gateway/BFF、OpenTelemetry、模块化单体优先。
|