<@ULVA73B9P> is there any way to speed up flows ru...
# ask-marvin
z
@Marvin is there any way to speed up flows run with
run_deployment
without spamming the server with polling requests?
m
To speed up flows run with
run_deployment
without spamming the server with polling requests, you can consider the following strategies: 1. Hybrid Execution Model: - Utilize Prefect's deployment interface to enable a more efficient way of executing flows by registering deployments only once and executing them independently. This can minimize excessive server requests. - Link: Prefect Deployments 2. Global Concurrency Limits: - Use the
concurrency
context manager to limit the number of parallel tasks running at the same time, ensuring that you don't exceed server resources and reducing the need for continuous polling. - Example:
Copy code
python
        from prefect import flow, concurrency

        @flow
        def my_flow():
            with concurrency("database", occupy=1):
                connection = psycopg2.connect("<connection_string>")
                cursor = connection.cursor()
                cursor.execute(query)
                result = cursor.fetchall()
                connection.close()
            return result
- Link: Global Concurrency Limits These approaches are designed to optimize flow runs and minimize the load on the server due to excessive polling. If you'd like more specific details or examples, feel free to ask.