PrefectHQ
prefect
BlogDocsChangelog

Use acquisition service pattern for lease-based concurrency slots

#19451
Comparing
fix/concurrency-thundering-herd
(
58b58a8
) with
main
(
6e30579
)
CodSpeed Performance Gauge
0%
Untouched
2
Ignored
6

Benchmarks

Passed

bench_task_decorator
benches/bench_tasks.py
CodSpeed Performance Gauge
0%
460.8 µs460.2 µs
bench_import_prefect_flow
benches/bench_import.py
CodSpeed Performance Gauge
0%
1.4 s1.4 s

Ignored

bench_flow_call[options0]
benches/bench_flows.py
Ignored
CodSpeed Performance Gauge
+49%
165.2 ms110.9 ms
bench_task_submit
benches/bench_tasks.py
Ignored
CodSpeed Performance Gauge
-18%
5.7 ms6.9 ms
bench_flow_call[options1]
benches/bench_flows.py
Ignored
CodSpeed Performance Gauge
0%
107.6 ms107.4 ms
bench_flow_decorator
benches/bench_flows.py
Ignored
CodSpeed Performance Gauge
+11%
6.3 ms5.7 ms
bench_import_prefect
benches/bench_import.py
Ignored
CodSpeed Performance Gauge
0%
1.1 s1.1 s
bench_task_call
benches/bench_tasks.py
Ignored
CodSpeed Performance Gauge
-5%
158.1 ms166.9 ms

Commits

Click on a commit to change the comparison range
Base
main
6e30579
+0.03%
fix: serialize concurrency acquisition requests when requesting lease-based concurrency Adds ConcurrencySlotAcquisitionWithLeaseService to serialize acquisition attempts for lease-based concurrency limits. This prevents concurrent retry attempts when multiple tasks wait for available slots. The service uses a singleton pattern (one instance per unique set of limit names) with a single-threaded queue to process acquisition requests serially. This matches the pattern used by ConcurrencySlotAcquisitionService for non-lease-based concurrency. Benefits: - Prevents thundering herd when many tasks retry simultaneously - Reduces unnecessary API load - Improves slot acquisition efficiency - Adds limit names to debug logging for easier troubleshooting Related to ENGPAR-11 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
58b58a8
2 days ago
by bunchesofdonald
© 2025 CodSpeed Technology
Home Terms Privacy Docs