Skip to content
Get started
Get started
Operate and Scale N Brokers
View Markdown
examples · production operations

Scale the fleet without breaking its invariants.

Client code stays identical. Reliable multi-broker fleets come from unique broker IDs, bounded PostgreSQL pools, readiness-gated routing, and clean rollouts.

Day-2 Fleet Operations

Probe /ready per pod, run doctor --pg <url>, and coordinate schema upgrades

check DOC doctor --pg verify schema & pool monitor OBS top + /ready per-pod health protect UPG Recreate Roll safe schema bumps BAK PG PITR provider snapshots Scale replicas horizontally as long as replicas × poolSize fits PG max_connections
Predictable operations: keep each pod on its own BUNQUEUE_BROKER_ID, scrape /prometheus, and never mix binary versions across a schema bump.
InvariantRequired configuration
Storage driver & URLBUNQUEUE_STORAGE_DRIVER=postgres + same primary DB or HA endpoint
NamespaceSame BUNQUEUE_POSTGRES_NAMESPACE across brokers sharing queues
Broker IDUnique, stable BUNQUEUE_BROKER_ID per active process (e.g., Pod name; never --scale a hardcoded ID)
VersionSame binary version for breaking bumps; mixed vN/vN+1 supported during additive expand rollouts (min_compatible_version <= vN)
SQLite path & clockUnset / empty (DATA_PATH=''); PostgreSQL DB time governs leases

Each broker defaults to 4 pooled SQL connections plus 1 LISTEN channel:

required connections = (broker replicas * (pool size + 1)) + migrations/admin + monitoring/failover headroom

Ten brokers at pool size 4 use 50 connections before operational headroom. Larger pools can raise lock contention and WAL pressure; tune against real payloads and latency. Place one TCP service or L4 load balancer in front of /ready (200) brokers; because TCP balances per connection, monitor broker-local connection counts alongside global queue depth.

  • Security: keep PostgreSQL private with verified TLS (sslmode=verify-full), inject credentials from a secret manager, enable AUTH_TOKENS, gate metrics with METRICS_AUTH=true, terminate client TLS natively or at a trusted proxy, and run non-root.
  • Live fleet triage: point bunqueue top at the single Service VIP to auto-discover PostgreSQL peers in [8] Nodes, or pass --nodes (BUNQUEUE_NODES) to poll brokers directly for summed throughput, tail latency, and per-node focus.
Alert signalAction trigger
/readyBroker stays non-ready past a brief DB blip
Queue depth & oldest ageBacklog grows beyond SLO
Lease recoveries & DLQ sizeFrequent worker stalls or rising permanent failures
TCP command latencyOperations approach client commandTimeout
PostgreSQL pool, locks & WALNear max_connections, lock waits, vacuum lag, or replica lag

Upgrades, backups, and pre-production drills

Section titled “Upgrades, backups, and pre-production drills”
  • Upgrades: both Queue and Workflow migration tables record min_compatible_version. Additive expand releases (1 <= min_compatible_version <= vN) support zero-downtime RollingUpdate without downgrading DDL (and existing v22/v2 databases backfill only the migrations column without locking live tables); breaking schema bumps (min_compatible_version > vN, <= 0, or NULL) fail closed—rehearse PITR restore on a clone, drain and stop old brokers, start one new broker to run the migration and verify counts, then start the remaining brokers at the same version.
  • Backups: use PostgreSQL-native physical backups and PITR (bunqueue’s SQLite S3 tool does not apply). PITR restores may replay jobs ACKed after the recovery point, so external side effects must be idempotent.
  • Pre-launch drills: kill an active broker to verify lease recovery and stale-token fencing; reset DB connections to test client reconnect; fill and replay the DLQ; pause/resume across brokers; rehearse a PostgreSQL restore into a clean cluster.

Next: read the engineering validation report.