This blog post is written by Alexey Paramonov, Solutions Architect, ISV and Maximilian Schellhorn, Solutions Architect ISV
This blog post demonstrates a solution based on AWS Step Functions and Amazon API Gateway WebSockets to track execution progress of a long running workflow. The solution updates the frontend regularly and users are able to track the progress and receive detailed status messages.
Websites with long-running processes often don’t provide feedback to users, leading to a poor customer experience. You might have experienced this when booking tickets, searching for hotels, or buying goods online. These sites often call multiple backend and third-party endpoints and aggregate the results to complete your request, causing the delay. In these long running scenarios, a transparent progress tracking solution can create a better user experience.
The example provided uses:
The example provides different options to report the progress back to the WebSocket connection by using Step Functions SDK integration, Lambda integrations, or Amazon EventBridge.
The following diagram outlines the example:

To send the status updates back to the client via the WebSocket API, three options are explored:
As the diagram shows, the API Gateway workflow tasks starting with the prefix “Report:” send responses directly to the client via the WebSocket API. This is an example of the state machine definition for this step:
'Report: Workflow started': Type: Task Resource: arn:aws:states:::apigateway:invoke ResultPath: $.Params Parameters: ApiEndpoint: !Join [ '.',[ !Ref ProgressTrackingWebsocket, execute-api, !Ref 'AWS::Region', amazonaws.com ] ] Method: POST Stage: !Ref ApiStageName Path.$: States.Format('/@connections/{}', $.ConnectionId) RequestBody: Message: 🥁 Workflow started Progress: 10 AuthType: IAM\_ROLE Next: 'Mock: Inventory check'
This option reports the progress directly without using any additional Lambda functions. This limits the system complexity, reduces latency between the progress update and the response delivered to the client, and potentially reduces costs by reducing Lambda execution duration. A potential drawback is the limited customization of the response and getting familiar with the definition language.
To further customize response logic, create a Lambda function for reporting. As shown in point 4 of the diagram, you can also invoke a “ReportProgress” function directly from the state machine. This Python code snippet reports the progress status back to the WebSocket API:
apigw\_management\_api\_client = boto3.client('apigatewaymanagementapi', endpoint\_url=api\_url)apigw\_management\_api\_client.post\_to\_connection( ConnectionId=connection\_id, Data=bytes(json.dumps(event), 'utf-8') )
This option allows for more customizations and integration into the business logic of other Lambda functions to track progress in more detail. For example, execution of loops and reporting back on every iteration. The tradeoff is that you must handle exceptions and retries in your code. It also increases overall system complexity and additional costs associated with Lambda execution.
You can combine option 2 with EventBridge to provide a centralized solution for reporting the progress status. The solution also handles retries with back-off if the “ReportProgress” function can’t communicate with the WebSocket API.
You can also use AWS SDK integrations from the state machine to EventBridge instead of using API Gateway. This has the additional benefit of a loosely coupled and resilient system but you could experience increased latency due to the additional services used. The combination of EventBridge and the Lambda function adds a minimal latency, but it might not be acceptable for short-lived workflows. However, if the workflow takes tens of seconds to complete and involves numerous steps, option 3 may be more suitable.
This is the architecture:

Make sure you can manage AWS resources from your terminal.
To view the source code and documentation, visit the GitHub repo. This contains both the frontend and backend code.
To deploy:
git clone "https://github.com/aws-samples/aws-step-functions-progress-tracking.git" sam build && sam deploy --guided Alternatively, you can deploy the React-based frontend on your local machine:
cd progress-tracker-frontend npm start Now the application is ready to test.



The services used in this solution are eligible for AWS Free Tier. To clean up the resources, in the root directory of the repository run:
sam delete
This removes all resources provisioned by the template.yml file.
In this post, you learn how to augment your Step Functions workflows with low latency progress tracking via API Gateway WebSockets. Consider adding the progress tracking to your long running workflows to improve the customer experience and provide a reactive look and feel for your application.
Navigate to the GitHub repository and review the implementation to see how your solution could become more user friendly and responsive. Start with examining the template.yml and the state machine’s definition and see how the frontend handles WebSocket communication and message visualization.
For more serverless learning resources, visit Serverless Land.