Short answer: Yes—when you run flows on Kubernetes or ECS with Prefect workers, a task retry happens in the same container/pod (i.e., the same “machine”) because it’s part of the same flow run process.
Details and exceptions:
- Same container by default: With the default task runner (ConcurrentTaskRunner), Prefect orchestrates task retries inside the running flow container. No new pod/ECS task is created for a task retry.
- Distributed runners: If you’re using a distributed task runner like Dask or Ray, each retry may run on a different worker in that cluster.
- Flow-level retries or infra restarts: If the entire flow run is retried (flow retries) or the container is killed/preempted and resubmitted by the worker, Prefect will start a new pod/ECS task for the new attempt—so that will be a different machine.
Helpful docs:
- Task and flow retries:
Retries guide
- Kubernetes execution (work pools/workers):
Kubernetes guide
- ECS execution (work pools/workers):
ECS guide
- Distributed runners:
Dask integration