Is there any way to speed up the flow runs? Specif...
# ask-community
a
Is there any way to speed up the flow runs? Specifically, is there any way we can have the flows warmed up prior to running the flows instead of waiting to "Downloading flow code from storage at '/opt/app'" every time a flow run is triggered?
n
hey @Andrew - have you checked out
serve
yet?
Copy code
from time import sleep
from prefect import flow, serve

@flow
def subflow():
    pass

@flow(log_prints=True)
def foo(msg: str = "Hello marvin") -> str:
    print(msg)
    subflow()
    sleep(30)
    
if __name__ == '__main__':
    serve(foo.to_deployment("some_name"), limit=1)
a
We've actually been working on switching over to
serve
and
deploy
. I guess I didn't fully understand the benefits of
serve
. So, is if fair to say
serve
is generally faster because it is running on an existing infrastructure (therefore, no need to wait for infrastructure and downloading the flow code)?
n
yep! those are the 2 reasons i would say it’s faster
a
@Nate Is there a way to also speed up the "Scheduled" and "Pending" status of the flow runs?
n
> Is there a way to also speed up the "Scheduled" and "Pending" status of the flow runs? not sure i understand the question, are you asking if there's a way to get the flow into a
Running
state more quickly after being triggered?
a
Yes
Some of our flows take 2~3 seconds to run, but the ramp up time to get to
Running
takes 8~10 seconds.
n
hmm i'm not sure why that would be, i dont see behavior like that with serve. what kind of infra does your serve process run on?
a
The infra is essentially docker image deployed locally on kubernetes similar to this guide