﻿# Prefect concurrency and rate limits release slots differently

Prefect concurrency limits hold slots during an operation, while rate limits release them by decay; start frequency, simultaneous occupancy and slot-acquisition timeout are different controls.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/guide-prefect-concurrency-rate-slot-release/
Language: en

## Identify the scarce resource

An agent workflow calls a slow model service and also accesses a small database connection pool. A limit on starts per time interval does not necessarily protect the pool from long-lived operations. Prefect's [global-limit concepts](https://www.prefect.io/docs/v3/concepts/global-concurrency-limits) distinguish concurrency from rate control through slot release. First decide whether the resource constraint concerns active operations, arrival frequency or both.

## Hold concurrency slots across the protected work

The `concurrency` context manager acquires slots before entering protected code and releases them when the context exits. The [practical guide](https://www.prefect.io/docs/v3/how-to-guides/workflows/global-concurrency-limits) applies it to ordinary Python operations, not only entire Prefect flows. Put the boundary around the actual resource use. Releasing a slot immediately after submitting a long external job would measure submission time rather than that job's active resource consumption.

## Use decay for the desired start frequency

The rate-limit function requires a configured slot decay and releases capacity over time independently of operation duration. It can smooth starts without limiting how many slow requests remain active afterward. If both constraints matter, express both deliberately. Do not label a provider's frequency allowance as proof that the application cannot accumulate too many concurrent outstanding requests. The appropriate combination depends on the external service contract and the workflow's resource use.

## Keep acquisition timeout separate

The [synchronous API reference](https://reference.prefect.io/prefect/concurrency/sync/) defines `timeout_seconds` as time waiting to acquire slots. It does not give the protected function that same runtime deadline. A task can wait for capacity and then spend additional time in the model request. Account for those stages when setting the user-visible task budget, and inspect which stage actually timed out before changing an unrelated request duration.

## Verify occupancy with a controlled workload

Use harmless delayed operations to observe start times, active counts and release behavior. Confirm the named limit exists and is active before interpreting a run as evidence of enforcement. [Task budgets](/journal/learn-codex-task-budgets/) help relate waiting to useful completion; [tool observations](/journal/learn-codex-tool-observation/) distinguish acquisition and execution. Preserve the resource boundary with the configuration. A correct limit protects the intended resource rather than merely slowing a convenient part of the code.
