帮助设计与评估工作流编排系统的模式、状态机与故障处理方案
复制安装指令,让 AI 自动完成配置 · 推荐新手
请帮我安装 askskill 上的 "system-type-workflow-orchestration" 技能: 1. 下载 https://raw.githubusercontent.com/microsoft/amplifier-bundle-systems-design/main/skills/system-type-workflow-orchestration/SKILL.md 2. 保存为 ~/.claude/skills/system-type-workflow-orchestration/SKILL.md 3. 装好后重载技能,告诉我可以用了
我在设计一个包含下单、支付、库存、发货、通知的业务流程。请基于步骤数量、失败处理、可观测性和团队协作,判断应该采用 orchestration 还是 choreography,并给出取舍分析。
输出推荐方案,并说明适用条件、风险点和为什么另一种方式不合适。
请为订单处理流程设计一个状态机,包含主要状态、合法状态迁移、终态,以及每个非终态的超时策略,避免出现非法流转。
给出结构化状态机设计,明确状态、触发条件、超时和终止条件。
请评估一个长时运行工作流系统的设计,重点检查重试层级、超时层级、人工审批关卡、补偿逻辑和常见失败模式,并指出反模式。
输出风险清单、设计缺陷与改进建议,帮助判断系统是否适合上线或重构。
开发者或产品经理在规划包含条件分支、重试、超时与补偿的复杂流程时,可用它判断编排模式是否合适,并梳理整体流程结构。
团队在选型或评审工作流引擎、作业编排器时,可用这些模式和失效分析检查可观测性、故障处理和架构风险。
当流程具有明确阶段和合法流转约束时,可用状态机方法定义状态、迁移、终态与超时策略,减少流程卡住或非法执行的问题。
文档围绕工作流编排系统展开,介绍了编排与编舞两种模式的适用场景、优缺点与常见误区,并说明在复杂多步骤流程中为何集中式编排更易调试与治理。文档还讲解了用状态机建模流程的方法,强调显式状态迁移、终态定义以及为每个非终态设置超时策略,以降低长时运行流程中的失效风险。
Patterns, failure modes, and anti-patterns for long-running workflow and process orchestration systems.
Orchestration. A central coordinator owns the workflow definition and explicitly directs each step. The coordinator calls services, waits for results, handles failures, and decides what happens next. The entire flow is visible in one place. When to use. Complex multi-step processes (5+ steps). Flows with conditional branching, retries, timeouts, or compensation logic. When you need a single place to understand what the process does. When you need to answer "where is this order in the pipeline?" without querying every service. When to avoid. Simple event reactions (service A publishes, service B reacts). When the coordinator becomes a bottleneck or single point of failure you can't tolerate. When teams owning individual steps need to evolve independently without touching the orchestrator.
Choreography. Each service listens for events and decides what to do next. No central coordinator. The process is emergent from the event chain. When to use. Loosely coupled domains where services genuinely don't need to know about each other. Simple fan-out patterns (order placed → send email, update analytics, reserve inventory). When the number of steps is small (≤3) and failure handling is straightforward. When to avoid. When you catch yourself drawing the event flow on a whiteboard and it takes more than 60 seconds to explain. When debugging requires tracing events across 6 services to figure out why an order is stuck. When compensation logic is non-trivial — choreographed compensation is a nightmare to reason about.
The honest tradeoff. Choreography feels elegant and decoupled until something goes wrong. Orchestration feels heavy and centralized until you need to debug a production incident at 2am. Most teams that start with choreography for complex flows end up building an ad-hoc orchestrator anyway — they just don't call it that, and it's worse than a purpose-built one.
What it is. Model workflow as a finite set of states with explicit transitions between them. Each transition has a trigger (event, condition, timeout) and may have side effects. When to use. Workflows with well-defined states and transitions: order processing, approval flows, document lifecycle, account provisioning. When you need to enforce that certain transitions are illegal (e.g., can't ship before payment). When auditors ask "what are all the possible states this entity can be in?" When to avoid. Workflows where the number of states explodes combinatorially (parallel execution with many branches). Purely sequential pipelines where a state machine adds ceremony without value. Key discipline. Every state machine needs an explicit terminal state and a timeout for every non-terminal state. A state machine without timeouts is a state machine that accumulates orphaned instances forever.
What it is. Model workflow as a directed acyclic graph where nodes are tasks and edges are dependencies. Tasks with no unmet dependencies can execute in parallel. When to use. Data pipelines, build systems, ETL jobs, ML training pipelines — anywhere the work is a dependency graph with parallelism opportunities. When tasks are largely independent and the critical path optimization matters. When to avoid. Workflows with cycles (approval → rejection → resubmission). Workflows where the graph shape depends on runtime results (conditional branching makes DAGs awkward). Long-running workflows with human interaction — DAG engines are typically designed for batch, not for processes that pause for days. Key systems. Airflow, Prefect, Dagster, Argo Workflows. Each has different opinions about dynamic DAGs, task isolation, and scheduling.
…
它用于设计和评估工作流编排系统,重点覆盖长时运行流程、状态机、saga 协调、人工关卡、重试与超时层级,以及失败模式分析。
文档指出,当流程步骤较多、存在条件分支、重试、超时或补偿逻辑,并且需要在一个地方看清全流程时,更适合用 orchestration。对于简单事件响应和少量步骤,choreography 更合适。
文档强调,状态机应有明确状态与迁移,并且每个非终态都要设置超时,另外必须定义显式终态。这有助于避免流程无限挂起或出现非法流转。
帮助设计可离线运行的边缘系统,处理同步、冲突恢复与弱网故障场景。
帮助设计与评估企业系统集成方案,覆盖遗留改造、网关、事件与失效模式。
用于按七步法系统审查架构设计,识别风险、权衡并产出改进建议。
用 Unix/Linux 设计哲学评估系统方案的可组合性、简洁性与关注点分离。
帮助用户设计或评估基于 Azure 的系统架构与运维方案
帮助设计和评估多租户SaaS的平台隔离、计量计费与稳定性方案
帮助设计和评估事件驱动、消息驱动与异步工作流系统架构。
帮助设计与评估实时协作系统的连接、同步、冲突处理与故障模式
帮助设计与评估数据管道架构,覆盖批流处理、调度、质量与故障策略。
帮助你设计或评估Web服务架构、API模式、扩展性与可靠性问题。
帮助用户设计与评估分布式系统的核心机制、权衡与故障处理方案
用于按九阶段方法系统化推进架构设计、权衡取舍与迁移规划。