From 73d473a79bb845f59c2c2bc9c3bf231400ef68c5 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Thu, 9 Apr 2026 14:19:04 -0500 Subject: [PATCH] Switch Oban to the Pro Smart engine, rate-limit ERA5 CDS Wire up the Oban Pro Smart engine in base + runtime config and add the Pro migration (oban_producers, oban_crons, oban_queues tables + the v1.6 partition/workflow index additions on oban_jobs). On the Smart engine the era5_batch queue now has a global_limit of 4 in-flight jobs across the cluster and a rate_limit of 10 jobs per hour so slow Copernicus CDS submit/poll cycles can't exhaust our daily request budget when a backfill kicks off. --- config/config.exs | 1 + config/runtime.exs | 11 +++++++++-- priv/repo/migrations/20260409191733_add_oban_pro.exs | 7 +++++++ 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 priv/repo/migrations/20260409191733_add_oban_pro.exs diff --git a/config/config.exs b/config/config.exs index fc8e291b..cfe32727 100644 --- a/config/config.exs +++ b/config/config.exs @@ -43,6 +43,7 @@ config :microwaveprop, MicrowavepropWeb.Endpoint, live_view: [signing_salt: "Gdq36xze"] config :microwaveprop, Oban, + engine: Oban.Pro.Engines.Smart, repo: Microwaveprop.Repo, queues: [solar: 1, weather: 20, enqueue: 1, hrrr: 5, terrain: 4, commercial: 2, iemre: 10, propagation: 1], plugins: [ diff --git a/config/runtime.exs b/config/runtime.exs index da797fdf..8ba1734a 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -129,8 +129,11 @@ if config_env() == :prod do ], secret_key_base: secret_key_base - # Production Oban: live scoring, polling, and on-demand QSO enrichment + # Production Oban: live scoring, polling, and on-demand QSO enrichment. + # Runs on the Oban Pro Smart engine so we can use global_limit / rate_limit + # to protect rate-limited upstreams (Copernicus CDS in particular). config :microwaveprop, Oban, + engine: Oban.Pro.Engines.Smart, # Per-pod concurrency (×3 pods = effective cluster total) queues: [ propagation: 1, @@ -141,7 +144,11 @@ if config_env() == :prod do terrain: 3, iemre: 3, era5: 2, - era5_batch: 2, + era5_batch: [ + local_limit: 2, + global_limit: 4, + rate_limit: [allowed: 10, period: {1, :hour}] + ], rtma: 2, backfill_enqueue: 1 ], diff --git a/priv/repo/migrations/20260409191733_add_oban_pro.exs b/priv/repo/migrations/20260409191733_add_oban_pro.exs new file mode 100644 index 00000000..4ceee61f --- /dev/null +++ b/priv/repo/migrations/20260409191733_add_oban_pro.exs @@ -0,0 +1,7 @@ +defmodule Microwaveprop.Repo.Migrations.AddObanPro do + use Ecto.Migration + + def up, do: Oban.Pro.Migration.up() + + def down, do: Oban.Pro.Migration.down() +end