欢迎使用 FlowZap,快速、清晰、掌控的绘图应用。

无服务器 Step Functions 编排架构

Architecture

AWS Step Functions 编排架构图,展示状态机工作流,包括选择状态、并行处理、等待回调模式以及失败步骤的补偿回滚。该模板模拟无服务器工作流编排,复杂的多步骤流程定义为具有内置错误处理和重试逻辑的状态机。对于构建需要人工审批或长时间运行流程的可靠无服务器工作流的团队至关重要。

完整 FlowZap 代码

Trigger { # Trigger
n1: circle label:"Start Execution"
n2: rectangle label:"API Gateway / EventBridge"
n3: rectangle label:"Invoke Step Function"
n1.handle(right) -> n2.handle(left)
n2.handle(right) -> n3.handle(left) [label="StartExecution"]
n3.handle(bottom) -> StateMachine.n4.handle(top) [label="Input JSON"]
}
StateMachine { # AWS Step Functions
n4: rectangle label:"Validate Input (Task)"
n5: diamond label:"Order Type?"
n6: rectangle label:"Standard Order Path"
n7: rectangle label:"Express Order Path"
n8: rectangle label:"Parallel Processing"
n9: rectangle label:"Wait for Approval"
n10: diamond label:"Approved?"
n11: rectangle label:"Execute Final Step"
n12: rectangle label:"Compensation Rollback"
n13: circle label:"End State"
n4.handle(right) -> n5.handle(left)
n5.handle(right) -> n6.handle(left) [label="Standard"]
n5.handle(bottom) -> n7.handle(top) [label="Express"]
n6.handle(right) -> n8.handle(left)
n7.handle(right) -> n8.handle(left)
n8.handle(right) -> n9.handle(left) [label="Map State"]
n9.handle(right) -> n10.handle(left) [label="Callback"]
n10.handle(right) -> n11.handle(left) [label="Yes"]
n10.handle(bottom) -> n12.handle(top) [label="No"]
n11.handle(right) -> n13.handle(left)
n12.handle(right) -> n13.handle(left) [label="Rolled Back"]
n8.handle(bottom) -> Lambdas.n14.handle(top) [label="Invoke"]
}
Lambdas { # Lambda Functions
n14: rectangle label:"Payment Lambda"
n15: rectangle label:"Inventory Lambda"
n16: rectangle label:"Notification Lambda"
n17: rectangle label:"Error Catcher Lambda"
n14.handle(right) -> n15.handle(left) [label="Charge"]
n15.handle(right) -> n16.handle(left) [label="Reserve"]
n16.handle(top) -> StateMachine.n9.handle(bottom) [label="Result"]
n17.handle(top) -> StateMachine.n12.handle(bottom) [label="Error Info"]
}

为什么需要这个工作流?

Coordinating multi-step serverless workflows with direct Lambda-to-Lambda calls creates brittle chains that are hard to monitor and debug. Step Functions provide visual workflow orchestration with built-in state management, error handling, retries, and human approval gates—all without writing coordination code.

工作原理

  1. Step 1: An API Gateway or EventBridge trigger starts the Step Function execution with input JSON.
  2. Step 2: The state machine validates input and routes to the appropriate processing path.
  3. Step 3: Parallel states execute multiple Lambda functions simultaneously.
  4. Step 4: Wait states pause execution for human approval callbacks.
  5. Step 5: Error catchers route failures to compensation Lambda functions for rollback.
  6. Step 6: The final state returns the execution result or marks the saga as rolled back.

替代方案

Direct Lambda chaining is simpler but lacks visibility and error handling. Temporal.io provides more powerful workflow orchestration but requires server management. This template shows AWS-native serverless orchestration.

Key Facts

Template Name无服务器 Step Functions 编排架构
CategoryArchitecture
Steps6 workflow steps
FormatFlowZap Code (.fz file)

相关模板

无服务器事件处理架构

Architecture

无服务器事件处理架构图,S3、DynamoDB Streams、API Gateway 和 CloudWatch 触发器调用 Lambda 函数,由 Step Functions 编排,通过 SQS 扇出并使用死信队列进行错误处理。该模板展示如何完全从托管无服务器组件构建复杂的事件处理管道,无需配置或管理任何服务器。适合需要弹性扩展和内置容错能力的数据处理工作流。

无服务器多云架构

Architecture

多云无服务器架构图,展示基于 DNS 的流量路由在 AWS 和 Azure 区域之间切换、健康检查失败时的自动故障转移以及跨云提供商的双向数据复制与冲突解决。该模板模拟多云策略以实现最大可用性和供应商独立性,使用 AWS(Lambda、DynamoDB)和 Azure(Functions、Cosmos DB)的无服务器服务。对于需要云提供商冗余的企业至关重要。

Saga 编排模式架构

Architecture

Saga 编排架构图,中央编排器协调跨订单、库存和支付服务的多步骤分布式事务,具有专用的补偿链用于失败时的回滚。该模板模拟基于编排的 Saga 模式,单个协调器管理事务生命周期并在任何步骤失败时触发补偿操作。对于实施不使用两阶段提交的可靠分布式事务的架构师至关重要。

Saga 编舞模式架构

Architecture

Saga 编舞架构图,订单、支付和库存服务通过领域事件协调而无需中央编排器,每个服务发布和订阅驱动事务前进或触发补偿的事件。该模板模拟去中心化的 Saga 方法,服务自主响应事件,减少单点故障但增加了跟踪 Saga 状态的复杂性。适合偏好服务自治而非集中控制的团队。

Saga 旅行预订架构

Architecture

旅行预订 Saga 架构图,将航班、酒店和租车预订编排为单一分布式事务,任何预订步骤失败时自动补偿取消所有预订。该模板模拟经典的 Saga 用例,多个独立服务必须全部成功或全部回滚,确保旅客不会出现部分预订。非常适合用真实业务场景演示 Saga 模式。

熔断器弹性架构

Architecture

熔断器弹性架构图,展示完整的状态机,包括关闭、打开和半开状态、故障阈值跟踪、恢复计时器以及保护服务免受级联故障的降级响应策略。该模板详细可视化熔断器模式,包括熔断器如何根据成功和失败计数在状态之间转换。对于构建在负载下优雅降级的容错微服务至关重要。

返回所有模板