Previous commit (3c988a5f) switched oban_pro to the licensed hex repo at deploy time. Reverting that — keep all three Pro packages vendored so prod image builds don't depend on oban.pro reachability or auth on every CI run. oban_pro 1.7.0 dropped into vendor/oban_pro via `mix hex.package fetch oban_pro 1.7.0 --repo=oban --unpack`. mix.exs goes back to `path: "vendor/oban_pro"` (matching oban_met / oban_web, which were already vendored — and stay vendored since the licensed repo only has older versions of those: 0.1.11 / 2.10.6 vs the 1.1.0 / 2.12.1 we vendor). Schema migration from3c988a5fstays — 1.7.0 tables/indexes are already applied. No code changes.
54 lines
1.3 KiB
Markdown
54 lines
1.3 KiB
Markdown
# Queues
|
|
|
|
Consider a dedicated queue when you need global concurrency, rate limiting, isolation, or different SLAs.
|
|
|
|
## Global concurrency
|
|
|
|
Limit concurrent jobs across all nodes:
|
|
|
|
```elixir
|
|
# 10 jobs total across all nodes
|
|
my_queue: [global_limit: 10]
|
|
|
|
# 10 global, but max 3 per node
|
|
my_queue: [local_limit: 3, global_limit: 10]
|
|
|
|
# Exactly 1 job at a time cluster-wide
|
|
my_queue: [global_limit: 1]
|
|
```
|
|
|
|
## Rate limiting
|
|
|
|
Control throughput over time:
|
|
|
|
```elixir
|
|
# 60 jobs per minute
|
|
my_queue: [rate_limit: [allowed: 60, period: {1, :minute}]]
|
|
|
|
# 1000 jobs per hour
|
|
my_queue: [rate_limit: [allowed: 1000, period: {1, :hour}]]
|
|
|
|
# 10 jobs per 30 seconds
|
|
my_queue: [rate_limit: [allowed: 10, period: 30]]
|
|
```
|
|
|
|
Algorithms: `:sliding_window` (default, smooth), `:fixed_window` (simple resets), `:token_bucket` (allows bursts):
|
|
|
|
```elixir
|
|
my_queue: [rate_limit: [allowed: 100, period: {1, :minute}, algorithm: :token_bucket]]
|
|
```
|
|
|
|
## Partitioning
|
|
|
|
Apply limits per-partition instead of queue-wide (partition is nested inside the limit):
|
|
|
|
```elixir
|
|
# Global limit of 1 per worker
|
|
my_queue: [global_limit: [allowed: 1, partition: :worker]]
|
|
|
|
# Global limit of 1 per tenant_id from args
|
|
my_queue: [global_limit: [allowed: 1, partition: [args: :tenant_id]]]
|
|
|
|
# Rate limit per account_id
|
|
my_queue: [rate_limit: [allowed: 100, period: {1, :minute}, partition: [args: :account_id]]]
|
|
```
|