Hi, How can I set Prefect limit on the number of f...
# prefect-server
h
Hi, How can I set Prefect limit on the number of flows an agent can run? I want to make sure the agent only runs 1 flow. I'm using the cloud version with standard option.
k
Hey @Harish, it’s not a limit on the agent. We limit on the Flow Level with concurrency limits
h
@Kevin Kho Do you think its possible to limits runs to an agent? Or are there any GraphQL API query I could use to help the cause? My training get cancelled when multiple flows run on one agent due to memory issue.
I tried the flow and task limits, its not what I was looking for..
k
Why does flow run concurrency not work? You can apply it on the agent label
upvote 1
h
I have 3 agents M1(label=small), M2(label=small), M3(label=small). They can run only one flow. If they try to run 2 flows at a time, it will fail. When I run a flow, I want prefect to orchestrate and pick an agent to run. So when we run a flow the second time, I don't want Prefect to pick M1 twice, instead pick M2/M3 if its available. I tried adding flow limit like small=1 but it would reach the limit when M1 is running and wont orchestrate another run to M2/M3. The goal for me is submit runs to prefect which would then run on an agent but avoid running multiple runs on one agent. If there are no free agents, wait for an agent to become free. Please let me know if I'm missing any labels/concurrency tags that could help solve this...
a
@Harish I think what you’re looking for is a load balancer. You want to randomly split work across 3 machines and this is not what Prefect agents are for. Prefect orchestrates your flows and their states, not compute resources. There are a couple of options you may explore: 1. The easiest: manually distribute work by assigning different labels to your 3 agents, e.g. small-m1, small-m2, small-m3 and then using concurrency limit of 1 for each agent to ensure only one flow ever runs on one agent 2. Using Amazon ECS, attach those 3 instances to an ECS cluster, and create an Application Load Balancer that will randomly distribute work across those 3 instances. Then, you can have a single ECS agent in Prefect with concurrency limit of 3 - this way you can ensure that there are at most 3 flows running on your cluster, and load balancer would ensure they are distributed appropriately. 3. Setting up a Kubernetes Service with Round Robin load balancer, similar to #2 The option #1 would be the easiest to set up, but #2 and #3 would be likely better for scale e.g. in case you would need more machines in the future.
h
Thank you @Anna Geller I followed your advice 1 and it seems to be working now.
🎉 1