Hi Everyone, Had one case where i need a flow leve...
# ask-community
n
Hi Everyone, Had one case where i need a flow level concurrency. like in the workqueues we can set the concurrency. is it possible to set the concurrency at flows level ?
b
Hi Nimesh! There is deployment-level concurrency available, which limits how many flow runs of a particular deployment can be active at a given time.
n
Hi Bianca, Thankyou for the response But, Let suppose i have 4 deployment and i put concurrency 1 to each deployment. So then at one point of time 4 flows can be in the running state But i want only 2 flows in the running state at a given point of time
Also i am using prefect 2.7.7 currently
b
Hmm.. if that's the case then I'd say work queue and workpool concurrency would probably be your best bet. Is there a reason you're looking for an alternative?
n
We have 4 ai algorithms which correspond to 4 different deployment with diff queues attached to it And each of the 4 algorithms has 4 dockers which requires high compute and since and this is On Premise client so resource is a issue here thats why we want to run only 2 algo at a time
b
I see. So maybe you could try this? 1. Create a single work pool for all 4 of your deployments. 2. Set a concurrency limit of 2 on this work pool. 3. Assign all 4 deployments to this work pool, each with its own work queue. That way regardless of which deployment or work queue a flow run comes from, only 2 will be running concurrently across all deployments. You could even designate the priority of the work queues if there is an algorithm that takes precedence over the others.
n
Ahh i see this might get the job done, just to confirm This is possible in prefect 2.7.7 ?
b
for sure!
n
Thanks bianca 🫡
Hi bianca, i am trying to create a workpool as per your suggestions but i am not able to see on the prefect UI prefect deployment build -sb "remote-file-system/inferencing-bucket" -n "rb deployment" -q "rb" "rb_frac.py:start_rbfracture_inferencing This is one of the example of how i created the deployment What modifications in this line i need to make so that concurrency can be set ?? Please help 🙏
Hi Bianca, i have set the pool concurrency limit to 2 but i can see the total running flows limit is 5 (which is my workqueue limit)
b
Hi Nimesh, thanks for sharing. What command did you use to start your agent?
Something like this?
prefect agent start -q my-queue
or did you run
prefect agent start -q my-queue -p default-agent-pool
?
n
when i have used this
prefect agent start -q my-queue -p default-agent-pool
then my flows were stuck into Late state and when i ran
prefect agent start -q my-queue
then queue were assinged into default-agent-pool (which i was expecting) but when i put concurrency in the default-agent-pool for example 2 then it did not restrict the flow to 2 reather it gets restricted to 5 which was a concurrency limit of my work queue
b
> when i have used this
prefect agent start -q my-queue -p default-agent-pool
then my flows were stuck into Late state I think adding the
-p
argument is needed for the pool-level concurrency to be respected, then. 🤔 As for the pool accumulating late runs, are there any flow runs stuck in a
PENDING
or
CANCELLING
state? Any runs in those states will also count against the concurrency work pool's limit.
n
not there is aren't any flow runs that are stuck into PENDING or CANCELLING. also do i need to change anything in this
prefect agent start -q my-queue -p default-agent-pool
or
prefect agent start -q my-queue
command becasue in the first command -p is there. ?
b
The only thing you need to change about this command would be the queue name and pool name (so that it matches your own):
prefect agent start -q my-queue -p default-agent-pool