Badger
v1.1.0released November 13

Reliable background jobs, no broker required

Badger is a background job runner that uses plain PostgreSQL as its queue, with retries, schedules and nothing else to operate.

$ curl -fsSL https://eu.gateway.fivestats.org/install.sh | sh
$ badger enqueue send_welcome '{"user": 42}'enqueued job 1842$ badger jobs --state done --limit 11842 send_welcome done 0.21s

Why Badger

Small, predictable and well documented.

Transactional enqueue

Jobs are rows. Insert one in the same transaction as your data and it exists exactly when the data does.

Retries with backoff

Failed jobs are retried with exponential backoff and jitter, up to a limit you set per queue.

Fast pickup

Workers use LISTEN/NOTIFY to pick up new jobs within milliseconds, and SKIP LOCKED to never collide.

Schedules

Run jobs on cron schedules. Only one worker enqueues each run, however many you start.

Any language

Workers call your code over a small HTTP or stdin protocol, so jobs can be written in anything.

Metrics

Queue depth, latency and failures as Prometheus metrics, ready for your dashboards.

Readable configuration

Badger is configured with a single TOML file. Every option has a sensible default and can be overridden from the environment, which makes it easy to run in containers and CI.

Configuration reference →

# /etc/badger/badger.toml
database_url = "postgres://badger@localhost/app"
queues = ["default", "mail"]
concurrency = 20
timeout = "5m"

[handler]
url = "http://127.0.0.1:8080/jobs"

[metrics]
listen = "127.0.0.1:9187"