add OBAN_QUEUE_SCALE env var to reduce queue concurrency for staging (#41)

staging was hitting postgres max_connections due to 252 concurrent oban
workers plus pool connections. OBAN_QUEUE_SCALE divides all queue sizes
(e.g. "5" = 1/5th capacity). defaults to 1, no change for production.

Reviewed-on: graham/towerops-web#41
This commit is contained in:
Graham McIntire 2026-03-16 13:21:56 -05:00 committed by graham
parent 0154da18fe
commit cdc40b3f3a

View file

@ -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