Why is there a delay before an agent starts processing a flow?

I’m using prefect locally, with the UI and a locally running agent (or two).

When I start a flow from the UI, the agent picks up the new flow immediately, but there then appears to be a lag before it actually starts working on the flow.

While waiting it shows “pending” in the UI and the agent CLI doesn’t provide any updates for about 3 minutes… so I’m assuming it is simply waiting for some reason or another…?

I’m wondering if this is normal or possibly a delay in feedback to the UI?



My suspicion is that when working with large data files these files are first copied around in the background before the flow starts.

This behaviour doesn’t seem to happen when running the flow directly from python (i.e. not via the UI).

I’m still new to prefect… so take this with a grain of salt.

1 Like

Hi, welcome to Prefect Disourse, great to have you here. Could you provide more info about your setup?

  1. Are you on Prefect 1 or 2?
  2. How did you set up your agent?
  3. Can you try setting up a new conda virtual environment, installing and starting Prefect there and check out whether your deployment is set correctly? Check this topic for more on deployments: Prefect Deployments FAQ

Hi Team,

I had the same problem. I had a flow that runs every xx:00:00 (every day every hour). But it shows “pending” in the UI before the agent actually starts working on the flow. You can see in the log screenshot that there is a 45 second delay before the flow is executed, which is a lot in my case.

This is the logs for my agent :

I’m using prefect 2.6.7 on my local machine. Thank you! :slight_smile:

agent is a separate process, separate from a flow

Sorry, I meant to say that the agent starts running the flow.

All I meant was that when I schedule a task to run at a specific time, there is always a delay of a few seconds (15-45 seconds) before the flow actually starts running. I wanted to know if there was a way to remove this delay. Thanks

gotcha - this delay depends in the type of infra block. Serverless blocks have latency because they need to provision the infra. switching to an always-on instance and to something like Process or K8s job block could help reduce that latency at the cost of having to maintain that always-on instance

1 Like

Thank you for your response! This solved the issue. Also, I see that you solved this specific problem in this release prefect 2.6.8

1 Like