diff --git a/config/runtime.exs b/config/runtime.exs index 06175cd3..54e9e61c 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -145,6 +145,9 @@ if config_env() == :prod do [] end + # OBAN_QUEUE_SCALE divides all queue sizes (e.g. "5" = 1/5th capacity for staging) + oban_scale = String.to_integer(System.get_env("OBAN_QUEUE_SCALE") || "1") + config :libcluster, topologies: libcluster_topologies # Configure Swoosh to use Req for API requests @@ -156,19 +159,19 @@ if config_env() == :prod do repo: Towerops.Repo, shutdown_grace_period: to_timeout(second: 40), queues: [ - default: 10, - discovery: 10, + default: max(1, div(10, oban_scale)), + discovery: max(1, div(10, oban_scale)), # SNMP polling jobs - one per device - pollers: String.to_integer(System.get_env("POLLER_CONCURRENCY") || "50"), + pollers: max(1, div(String.to_integer(System.get_env("POLLER_CONCURRENCY") || "50"), oban_scale)), # Device monitoring jobs - health checks - monitors: 50, + monitors: max(1, div(50, oban_scale)), # Service checks - HTTP/TCP/DNS - checks: 50, - check_executors: 50, + checks: max(1, div(50, oban_scale)), + check_executors: max(1, div(50, oban_scale)), # Alert notifications (PagerDuty, email, etc.) - notifications: 25, - maintenance: 5, - weather: 2 + notifications: max(1, div(25, oban_scale)), + maintenance: max(1, div(5, oban_scale)), + weather: max(1, div(2, oban_scale)) ], plugins: [ # Cron jobs for periodic maintenance tasks