Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to limit flow run concurrency for separate served flows #12015

Closed
3 tasks done
jrbourbeau opened this issue Feb 16, 2024 · 2 comments
Closed
3 tasks done

Add option to limit flow run concurrency for separate served flows #12015

jrbourbeau opened this issue Feb 16, 2024 · 2 comments
Labels
enhancement An improvement of an existing feature

Comments

@jrbourbeau
Copy link
Contributor

First check

  • I added a descriptive title to this issue.
  • I used the GitHub search to find a similar request and didn't find it.
  • I searched the Prefect documentation for this feature.

Prefect Version

2.x

Describe the current behavior

Currently I can limit the number of concurrent flow runs when using the .serve() API with the limit= parameter:

from prefect import flow

@flow
def my_flow():
    ...
    
my_flow.serve(name="flow", limit=1)

This works great for a single flow, but when serving multiple flows I can't (to my knowledge) limit concurrent flow runs in a similarly convenient way. Setting limit= on the top-level prefect.serve(...) method limits concurrent flow runs for all the flows that are being served:

from prefect import flow, serve

@flow
def flow1():
    ...

@flow
def flow2():
    ...
    
d1 = flow1.to_deployment(name="flow1")
d2 = flow2.to_deployment(name="flow2")
serve(d1, d2, limit=1)

Describe the proposed behavior

It'd be great if I could do something like this:

from prefect import flow, serve

@flow
def flow1():
    ...

@flow
def flow2():
    ...
    
d1 = flow1.to_deployment(name="flow1", limit=1)
d2 = flow2.to_deployment(name="flow2", limit=10)
serve(d1, d2)

to independently limit the flow run concurrency for each flow being served.

Example Use

No response

Additional context

No response

@serinamarie
Copy link
Contributor

Hi @jrbourbeau, thanks for creating your first issue in Prefect :) This sounds like a nice add and we'll add it to our backlog! This will require some design for the runner to separate concurrency limits between different flows.

@aaazzam
Copy link
Collaborator

aaazzam commented Sep 27, 2024

This has been achieved in recent work, see #14934.

@aaazzam aaazzam closed this as completed Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

3 participants