awslabs / awslabs/aws-solutions-constructs

New Pattern: add Stepfunction Callback with the Task Token (Service Integration Pattern)

Open
#248 1 comment 0 reactions 1 assignee Claimed by @biffgaut View on GitHub
Backlog feature-request
Dominant language
TypeScript
Stars
1.4k
Forks
268
Avg merge
5h 18m
Merged PRs (30d)
5

Description

Step function has a callback pattern called 'Callback with Task Token' - https://docs.aws.amazon.com/step-functions/latest/dg/connect-to-resource.html. It allows for slower backends to respond rather than getting throttled and fail.

### Use Case

With some of the AI services like Rek & Comprehend, the TPS soft-limits may not be able to handle bursts or volume of streaming data. Having step function workflow, retries and data streams like MSK or Kinesis does reduce the throttling issues. But does not solve the problem where a step function task has a slow backend.

### Proposed Solution

Using the callback patttern, makes the stepfunction task wait for a response (through a task token) before proceeding to the next state. Proposing to to use an SQS queue with a lambda consumer that calls the service and return the response. Using lambda's concurrency and batching messages in the queue provides a great control on handling throttling issues.

As part of this construct, the proposal is to create a statemachine fragment (https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-stepfunctions.StateMachineFragment.html) that would allow it to be chained to a state machine definition.

### Other

https://zaccharles.medium.com/async-callbacks-with-aws-step-functions-and-task-tokens-9df97fe8973c
https://docs.aws.amazon.com/step-functions/latest/dg/connect-to-resource.html
https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-stepfunctions.StateMachineFragment.html

* [x] :wave: I may be able to implement this feature request
* [ ] :warning: This feature might incur a breaking change

---

This is a :rocket: Feature Request

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.