Hello Prefect community, I received a response fro...
# ask-community
i
Hello Prefect community, I received a response from Marvin stating that it's not possible to set a maximum queue size. Is this answer correct? If so, would it be recommended to implement queue size constraints from the application that calls Prefect instead? https://prefect-community.slack.com/archives/C04DZJC94DC/p1756192320192359
b
Hi @IIJ Toru Ikeda, what are trying to achieve? I can help answer your question if I better understand the desired outcome.
i
Hi @Brendan Dalpe, In the application we are developing, there are usually fewer than 100 tasks. However, we anticipate that due to some malfunction, a large number of tasks might be registered. For example, if the application enters an infinite loop due to a bug, we want to prevent Prefect from crashing. We also want to limit the number of tasks users can register based on the current queue size. Could you pleases advise on the appropriate way to implement such constraints?
b
Hi @IIJ Toru Ikeda, You can limit the number of concurrent task runs with tags. Take a look at this page in the documentation: https://docs.prefect.io/v3/how-to-guides/workflows/tag-based-concurrency-limits
I'm not 100% sure what you mean by "tasks users can register". Can you explain more about this?
i
Hi @Brendan Dalpe, Thank you for the information. However, what I want to confirm is not about concurrent execution, but rather about the number of tasks waiting in the queue. Specifically, I mean that when there are more than 100 tasks already waiting in the queue, I want to prevent users from registering any additional tasks.
Hi @Brendan Dalpe, I look forward to hearing from you.
Hi everyone, just following up on my earlier question in case it got missed. I'd really appreciate any insights or suggestions from anyone who might have experience with this. Thank you!
n
hi @IIJ Toru Ikeda - what queue are you talking about? when you run a prefect task, there's not necessarily a queue involved work queues are a proper noun in prefect that allow staggered delivery of deployment flow runs within a work pool so can you clarify what you mean by "task" and "queue" in your case?
i
Hi @Nate, Thank you for your reply! To be precise, the queue I'm referring to is the Work Queue, and the tasks are Flow runs. As Iunderstand it, Flow runs are registered to a Work Queue and marked as Scheduled before they are actually processed. Int this context, is it possible to set a limit on the number of Scheduled Flow runs that can be registered to Work Queue?
n
no, there are work queue concurrency limits, but that's about how many runs can leave
Scheduled
and start
Running
what would be your expected behavior if there were a max queue depth? would the API call to schedule the flow run fail?
i
@Nate Thank you. I Understand that Prefect dose not have such a feature.
what would be your expected behavior if there were a max queue depth?
Yes, I expect the API that scheduled Flow Runs to fail when the limit is exceeded. The would help prevent runaway behavior caused by bugs in our application, and also stop users from registering an excessive number of asynchronous tasks. If there is a recommended way to help limit the maximum queue depth in such cases, I would greatly appreciate your guidance.