Search code examples
amazon-web-servicesaws-step-functions

Difference between activites and the new callback-pattern feature in AWS Step Functions


AWS released a new feature for AWS Step Functions (Callback Pattern):

https://aws.amazon.com/about-aws/whats-new/2019/05/aws-step-functions-support-callback-patterns/

I wonder now, what's actually the difference to the already existing activities.

Let me sum that up for you:

  • a step function can wait for an activity and deliver certain input values to it
  • any service (e.g. CLI, EC2, lambda, etc.) can poll for a job on activity; do something and report back with an activity task success or failure.
  • the step functions then receives the error or the success

What is the difference to the newly announced callback pattern? In my eyes, it is actually totally the same - do I miss something?


Solution

  • Activities are poll-based and the callback pattern is push-based. Both let you manage asynchronous tasks.

    In an activity task, Step Functions waits for a worker to poll using GetActivityTask. When a match is made, Step Functions returns the state payload and a task token to the worker that made the request. This is useful, for example, when your workers reside in a datacenter. You have less network configuration to poll from the datacenter instead of opening VPN access.

    In the callback pattern, Step Functions pushes the payload and task token to a supported AWS service integration (Lambda, Fargate, ECS, SNS, and SQS). This is useful in serverless architectures, which tend to favor ephemeral compute and event-driven data flows. The task token may be delegated to other services before returning to Step Functions, too.

    Both require a worker to eventually return a result payload and the task token to Step Functions to advance the state machine to the next step.