Let me explain specifically about deployment concurrency limits and their collision strategies:
### Deployment Concurrency Limits
When you set a concurrency limit on a deployment, you're specifying how many flow runs from that specific deployment can run at the same time. For example, if you set a limit of 3, only 3 instances of that flow can run simultaneously.
### Collision Strategies
When a new flow run is triggered and you're already at the concurrency limit, Prefect needs to know what to do. This is where the collision strategies come in:
1. Enqueue
- When selected: If you try to run a new flow when at the limit, the new run will be queued
- The queued run waits in line and will start automatically when a running flow finishes
- Think of it like a waiting list at a restaurant - when a table (slot) becomes available, the next person in line gets seated
2. Cancel New
- When selected: If you try to run a new flow when at the limit, the new run will be cancelled immediately
- No queuing occurs - it's simply rejected
- Think of it like a "Sold Out" sign - once capacity is reached, new requests are turned away
### When to Use Each Strategy
Choose Enqueue when:
- All flow runs must eventually complete
- Order of execution matters
- Delayed execution is acceptable
- Example: Processing customer orders where every order must be processed, even if delayed
Choose Cancel New when:
- Time-sensitive operations where delayed execution isn't useful
- Real-time processing where stale data wouldn't be valuable
- Resource management is critical
- Example: Real-time monitoring where old data becomes irrelevant quickly
This is specifically about deployment-level concurrency limits, which are different from global concurrency limits (GCLs) that I discussed in my previous response. These strategies help you manage resource usage and flow execution at the individual deployment level.