Do tasks in step function Activities get completed in the order that they are assigned?

0

I am assuming that when creating a step function with an Activity (Task and external Worker), the tasks get polled in order, though there seems to be no official documentation on this (https://docs.aws.amazon.com/step-functions/latest/apireference/API_GetActivityTask.html). Can someone confirm if the tasks do run in order?

1 Answer
2
Accepted Answer

AWS Step Functions do not guarantee a strict first-in, first-out (FIFO) order for tasks within Activities. When you have a Step Function with an Activity, external workers poll for tasks using the GetActivityTask API call. While it's possible that tasks might often be retrieved in the order they were scheduled, there's no explicit guarantee from AWS that this will always be the case, especially under high load or in distributed environments.

A few important things to note:

- Concurrency: If you have multiple workers polling for tasks from the same activity, they can receive tasks concurrently. This means that even if Worker A starts a task before Worker B, Worker B might complete its task before Worker A.

- Heartbeating: Workers can send "heartbeat" updates to AWS Step Functions to ensure that they're still processing a task. If a worker stops sending heartbeats (perhaps it crashed), Step Functions can assign the task to another worker. In such scenarios, the strict order of task completion can be affected.

- Retries: If a task fails, and you've configured retries for that task, it will be retried. This can also affect the order of task completion.

- Service Guarantees: AWS services are designed for high availability and scalability. While they often provide strong consistency guarantees, strict FIFO processing isn't typically one of them unless explicitly stated (like in Amazon SQS FIFO queues).

If the order of task completion is crucial for your use case, you'll need to implement additional logic, either in your Step Function or in your external workers, to ensure that tasks are processed in the desired order. This could involve sequencing tokens, external state management, or other synchronization mechanisms.

profile picture
answered 8 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions