Charles Liu
09/29/2024, 12:57 AMMarvin
09/29/2024, 12:57 AMdatabase
and you set a concurrency limit of 5
for this tag, no more than 5 tasks with this tag will run simultaneously.
Source: Task Concurrency Limits
2. Global Concurrency Limits:
- You can set global concurrency limits using the Prefect CLI.
- Example commands:
- prefect gcl create my-concurrency-limit --limit 5
- prefect gcl update my-concurrency-limit --limit 10
- prefect gcl delete my-concurrency-limit
Source: Global Concurrency Limits
### Prefect 3.x:
1. Flow Concurrency Limits at Work Pool/Queue Level:
- Concurrency limits for flow runs are configured at the level of work pools and work queues.
- You can set these limits using the Prefect CLI or the Prefect Client.
Source: Flow Run Concurrency Limits
2. Task Concurrency Limits and Slot Decay:
- You can apply task concurrency limits using tags, similar to Prefect 2.x.
- Additionally, you can configure slot decay to control the rate at which concurrency slots become available again.
- Example:
- python @task def database_query(query):
- with concurrency("database", occupy=1):
Source: Task Concurrency Limits and Slot Decay
Using these mechanisms, you can effectively control the concurrency of your tasks and flow runs based on your specific needs and preferences. If you need more detailed guidance or examples, feel free to ask!