<@ULVA73B9P> what would happen if two different de...
# ask-marvin
t
@Marvin what would happen if two different deployments called the same flow or task simultaneously?
m
When two different deployments call the same flow or task simultaneously, Prefect's design allows for this concurrency. Tasks and flows in Prefect are designed to be idempotent, meaning they can be executed more than once without different results or side effects, as long as the inputs are the same. The concurrency behavior can be controlled using task runners such as the
DaskTaskRunner
or
RayTaskRunner
, which enable tasks to run in parallel across multiple workers, even if the tasks are part of different flow runs. For example, with a
RayTaskRunner
, you could submit tasks to be executed immediately, and the task runner will manage the execution of these tasks in parallel, across available computing resources, as demonstrated here: Running parallel tasks with Ray. Remember, you can control task execution order via dependencies as well, by using the
wait_for
parameter when calling a task to specify upstream task dependencies. Here's the documentation for controlling task execution order. In short, simultaneous execution is part of the normal behavior in Prefect and it has mechanisms to ensure that this is handled smoothly. But how exactly it handles it depends on the configuration of task runners and flow design.