<@ULVA73B9P> i want to have a rate limit at my dep...
# marvin-in-the-wild
h
@Marvin i want to have a rate limit at my deployment level. is it possible? provide ref.
m
You need rate limit whole deployment? lemme check. It seems there are some references to managing rate limits using concurrency controls in tasks and flows, though specific rate-limiting at the deployment level isn't explicitly documented. You can use global concurrency limits to throttle task submission and control the overall execution rate:
Copy code
python
import asyncio
from prefect.concurrency.asyncio import rate_limit

async def main():
    for _ in range(10):
        await rate_limit("rate-limited-api")
        print("Making an HTTP request...")

if __name__ == "__main__":
    asyncio.run(main())

from prefect import flow, task
from prefect.concurrency.sync import rate_limit

@task
def my_task(i):
    return i

@flow
def my_flow():
    for _ in range(100):
        rate_limit("slow-my-flow", occupy=1)
        my_task.submit(1)

if __name__ == "__main__":
    my_flow()
For more details, check the Prefect Guides on Global Concurrency Limits and Rate Limits Documentation.