Oban#
Oban is a robust job orchestration framework for Python, backed by PostgreSQL. Reliable, observable, and loaded with enterprise grade features.
Features#
Obanβs primary goals are reliability, consistency and observability.
Oban is a powerful and flexible library that can handle a wide range of background job use cases, and it is well-suited for systems of any size. It provides a simple and consistent API for scheduling and performing jobs, and it is built to be fault-tolerant and easy to monitor.
Oban is fundamentally different from other background job processing tools because it retains job data for historic metrics and inspection. You can leave your application running indefinitely without worrying about jobs being lost or orphaned due to crashes.
Advantages Over Other Tools#
Async Native β Built entirely on asyncio with async/await throughout. Integrates naturally with async web frameworks.
Fewer Dependencies β If you are running a web app there is a very good chance that youβre running on top of a SQL database. Running your job queue within a SQL database minimizes system dependencies and simplifies data backups.
Transactional Control β Enqueue a job along with other database changes, ensuring that everything is committed or rolled back atomically.
Database Backups β Jobs are stored inside of your primary database, which means they are backed up together with the data that they relate to.
Advanced Features#
Isolated Queues β Jobs are stored in a single table but are executed in distinct queues. Each queue runs in isolation, with its own concurrency limits, ensuring that a job in a single slow queue canβt back up other faster queues.
Queue Control β Queues can be started, stopped, paused, resumed and scaled independently at runtime locally or across all running nodes.
Resilient Queues β Failing queries wonβt crash the entire process, instead a backoff mechanism will safely retry them again in the future.
Job Canceling β Jobs can be canceled regardless of which node they are running on. For executing jobs, workers can check for cancellation at safe points and stop gracefully.
Triggered Execution β Insert triggers ensure that jobs are dispatched on all connected nodes as soon as they are inserted into the database.
Scheduled Jobs β Jobs can be scheduled at any time in the future, down to the second.
Periodic (CRON) Jobs β Automatically enqueue jobs on a cron-like schedule. Duplicate jobs are never enqueued, no matter how many nodes youβre running.
Job Priority β Prioritize jobs within a queue to run ahead of others with ten levels of granularity.
Historic Metrics β After a job is processed the row isnβt deleted. Instead, the job is retained in the database to provide metrics. This allows users to inspect historic jobs and to see aggregate data at the job, queue or argument level.
Node Metrics β Every queue records metrics to the database during runtime. These are used to monitor queue health across nodes and may be used for analytics.
Graceful Shutdown β Queue shutdown is delayed so that slow jobs can finish executing before shutdown. When shutdown starts queues are paused and stop executing new jobs. Any jobs left running after the shutdown grace period may be rescued later.
Telemetry Integration β Job life-cycle events are emitted via Telemetry integration. This enables simple logging, error reporting and health checkups without plug-ins.
π Oban Pro#
Oban Pro is a licensed add-on that expands what Oban is capable of while making complex workflows possible.
Optimizations β Switch to Pro for automatic bulk inserts, bulk acking, and accurate orphan rescue.
Multi-Process Execution β Bypass the GIL and utilize multiple cores for CPU-intensive workloads. Just switch from
oban starttoobanpro start.Smart Concurrency β Global limits across all nodes, rate limiting (e.g., 60 jobs/minute), and partitioned queues that apply limits per worker, tenant, or any argument.
Workflows β Compose jobs with dependencies for sequential, fan-out, and fan-in patterns. Sub-workflows, cascading functions, and runtime grafting for dynamic pipelines.
Unique Jobs β Prevent enqueueing duplicate jobs based on configurable fields and time windows.
Requirements#
Oban requires:
Python 3.12+
PostgreSQL 14.0+
Installation#
See the [installation guide][docs] for details on installing and configuring Oban for your application.
Quick Start#
Get up and running in just a few steps: define a worker (or decorate a function), enqueue jobs, and start processing with the CLI (or embedded mode).
Define a worker to process jobs:
from oban import worker, Snooze, Cancel @worker(queue="exports", max_attempts=5) class ExportWorker: async def process(self, job): # Check if user cancelled their export request if job.cancelled(): return Cancel("Export cancelled by user") report = await generate_report(job.args["report_id"]) # Not ready? Check again in 30 seconds (doesn't count as a failure) if report.status == "pending": return Snooze(seconds=30) await send_to_user(job.args["email"], report)
Enqueue jobs from anywhere in your app:
await ExportWorker.enqueue({"report_id": 123, "email": "[email protected]"})
Run with the CLI:
# Install the database schema (once) oban install --dsn postgresql://localhost/mydb # Start processing jobs oban start --dsn postgresql://localhost/mydb --queues exports:10
Or embed in your application (FastAPI, Django, etc.):
from oban import Oban oban = Oban(pool=pool, queues={"exports": 10}) async with oban: ... # Run your app
For more details, see the [full documentation][docs].
Getting Started