Integration
D2 · Resilient
D3 · Performance
~1 phút đọc

Step Functions & EventBridge — Orchestration & Event-Driven

Step Functions cho workflow orchestration (state machine), EventBridge cho event-driven architecture. Hai pattern bổ sung nhau.

step-functions
eventbridge
orchestration
event-driven
workflow

Sơ đồ tổng quan

Đang tải sơ đồ…

Tổng quan

Step Functions = orchestration (điều phối workflow phức tạp, có state). EventBridge = choreography (event-driven, loose coupling). Thường kết hợp: EventBridge trigger Step Functions workflow.

Step Functions Patterns

  • Standard workflow: tối đa 1 năm, exactly-once, trả phí theo state transition.
  • Express workflow: tối đa 5 phút, at-least-once, trả phí theo duration.
  • Optimized integrations: gọi trực tiếp 200+ AWS service (DynamoDB, SQS, ECS...) không cần Lambda.
  • Map state (Distributed): xử lý hàng triệu item song song (S3 inventory, CSV).
  • Wait for Callback (.waitForTaskToken): chờ external system hoàn thành.
  • Saga pattern: mỗi step có compensation transaction khi fail.

EventBridge Patterns

  • Event Bus: default (AWS events), custom (app events), partner (SaaS).
  • Rules: pattern matching trên event content (source, detail-type, detail fields).
  • Targets: Lambda, SQS, SNS, Step Functions, API Gateway, Kinesis, ECS task...
  • EventBridge Pipes: source → filter → enrich → target (point-to-point, no code).
  • EventBridge Scheduler: cron/rate/one-time, thay CloudWatch Events.
  • Archive & Replay: lưu events, replay lại cho debug/testing.
  • Schema Registry: auto-discover event schema, generate code bindings.

Khi nào chọn gì

  • Workflow có nhiều bước tuần tự, branching, retry → Step Functions.
  • Event routing từ nhiều source tới nhiều target → EventBridge.
  • Cron job / scheduled task → EventBridge Scheduler.
  • Point-to-point transform → EventBridge Pipes.
  • Long-running approval workflow → Step Functions + .waitForTaskToken.
Tip
Combo mạnh: EventBridge rule trigger Step Functions workflow → event-driven orchestration.
Nội dung liên quan