Running state for tasks with a given tag.
Tag-based task concurrency is different from Global concurrency limits, though they can be used to achieve similar outcomes. Global concurrency limits are a more general way to control concurrency for any Python-based operation, whereas tag-based concurrency limits are specific to Prefect tasks.
Execution behavior
Task tag limits are checked whenever a task run attempts to enter aRunning state.
If there are no concurrency slots available for any one of your task’s tags, it delays the transition to a Running state
and instructs the client to try entering a Running state again in 30 seconds
(or the value specified by the PREFECT_TASK_RUN_TAG_CONCURRENCY_SLOT_WAIT_SECONDS setting).
Configure task run concurrency limits
Flow run concurrency limits are set at a work pool, work queue, or deployment levelWhile task run concurrency limits are configured through tags (as shown below), flow run concurrency limits are configured through work pools and/or work queues.
- Prefect CLI
- Prefect API
- Terraform
- Prefect API by using
PrefectClientPython client - Prefect server UI or Prefect Cloud
CLI
You can manage task run concurrency with the Prefect CLI.| Command | Description |
|---|---|
| create | Create a concurrency limit by specifying a tag and limit. |
| delete | Delete the concurrency limit set on the specified tag. |
| inspect | View details about a concurrency limit set on the specified tag. |
| ls | View all defined concurrency limits. |
API
You can manage task run concurrency with the Prefect API.Terraform
You can manage task run concurrency with the Terraform provider for Prefect.Python client
To update your tag concurrency limits programmatically, usePrefectClient.orchestration.create_concurrency_limit.
create_concurrency_limit takes two arguments:
tagspecifies the task tag on which you’re setting a limit.concurrency_limitspecifies the maximum number of concurrent task runs for that tag.
PrefectClient.delete_concurrency_limit_by_tag, passing the tag:
PrefectClient.read_concurrency_limit_by_tag, passing the tag:
To see all of your limits across all of your tags, use PrefectClient.read_concurrency_limits.