Reducing overhead time for real time processing

Hi, I’m trying to use prefect for real time processing. Flow runs need to be completed within some seconds (couple of seconds, just the time needed for the execution). But most of the time spent in scheduling, especially from PENDING state to SCHEDULED state. So, an operation, whose execution just needs some couples of seconds, with prefect requires almost fifteen seconds. Is there a way to reduce this overhead time needed for scheduling in order to complete the flow run within couple of seconds?
Thanks.

2 Likes

Yes, you’re totally right! Redeploying infrastructure for every flow run is too slow for real-time workflows. I’d recommend running the flow instead as a service e.g. a K8s deployment or ECS service. Check this post for a detailed recipe:

1 Like

First of all, thank you for the quick response!
I don’t know if that post it’s suitable for this situation, maybe I’m lacking of some knowledge about Prefect.
The system I’m working on, has a prefect server running on a docker container. The user, via an API, should be capable of running the flow and retrieve the results (within couples of seconds as I said). So the API will call, via the Orion Client, the flow run execution.
The flow is “encapsulated” into a deployment so that can be called via the Orion API.
So is it that post suitable for this situation?
Thank you for your time!

1 Like

it is, it’s just that the real-time flow doesn’t run in a deployment. Alternatively it could run in a deployment with a while loop - the post discusses the pros and cons of each of these approaches

1 Like

Thank you!

1 Like