Why use queues?
Queues solve common concurrency challenges: Rate limiting:- Prevent overwhelming external APIs (OpenAI, Stripe, etc.)
- Control database connection usage
- Manage resource consumption
- Process per-user tasks sequentially
- Maintain ordering for critical operations
- Prevent race conditions
- Limit concurrent access to shared resources
- Prevent thundering herd problems
- Control system load
Default queue behavior
Every workflow automatically gets its own queue:- Queue name: Same as workflow ID
- Concurrency limit: From environment variable (
POLOS_DEFAULT_CONCURRENCY_LIMIT) - Behavior: Unlimited executions queue up, but only N run simultaneously
Custom queue limits
Set a specific concurrency limit for a workflowShared queues
Multiple workflows can share the same queue- Rate-limit API calls across multiple workflows
- Control database connection pooling
- Manage resource contention
Queue configuration options
1. Inline configuration
2. Queue name only
3. Queue object
Per-entity queuing (Concurrency keys)
Use concurrency keys to create separate queues per user, tenant, or entity:- Each unique
concurrency_keygets its own virtual queue - Concurrency limit applies per key (not globally)
- Perfect for multi-tenant systems
Serial execution
Force workflows to run one at a time:- Database migrations
- File system operations
- Operations with global side effects
Queue behavior
Queuing and execution
- Queued workflows wait until a slot opens
- FIFO order (first in, first out)
- No compute consumed while queued
Dynamic queue assignment
Override queue at invocation time:Queue restriction
Scheduled workflows cannot specify queues.Key takeaways
- Default queue per workflow - Named after workflow ID
- Concurrency limits control max simultaneous executions
- Shared queues rate-limit across multiple workflows
- Concurrency keys create per-entity virtual queues
- Scheduled workflows cannot customize queues