# tinyjobs: a django.tasks backend and worker on SQLite, Postgres or Redis

**URL:** <https://forum.djangoproject.com/t/tinyjobs-a-django-tasks-backend-and-worker-on-sqlite-postgres-or-redis/46293>\
**Category:** Show & Tell\
**Created:** [October 27, 2026, 3:49pm UTC](https://forum.djangoproject.com/t/tinyjobs-a-django-tasks-backend-and-worker-on-sqlite-postgres-or-redis/46293 "2026-10-27T15:49:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Piergiuseppe](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/piergiuseppe/32/33611_2.png) [@Piergiuseppe](https://forum.djangoproject.com/u/Piergiuseppe)\
**Post date:** [October 27, 2026, 3:49pm UTC](https://forum.djangoproject.com/t/tinyjobs-a-django-tasks-backend-and-worker-on-sqlite-postgres-or-redis/46293/1 "2026-10-27T15:49:19Z")

</div>

Hi everyone,

Django 6 ships `django.tasks`, a standard API for background tasks, but leaves the worker to third parties. I’ve been building **tinyjobs** , an open source job queue for Python, and it now includes a `django.tasks` backend plus the worker to run it.

The idea is that you don’t need a broker to start: the queue is a SQLite file. When you outgrow one machine you switch the URL to Redis and your task code stays the same.

```python
# settings.py
INSTALLED_APPS = [..., "tinyjobs.contrib.django"]

TASKS = {
    "default": {
        "BACKEND": "tinyjobs.contrib.django.TinyJobsBackend",
        "OPTIONS": {"url": "sqlite:///jobs.db"},
    }
}

```

```python
# shop/tasks.py
from django.tasks import task

@task
def send_receipt(order_id: int) -> None:
    ...

send_receipt.enqueue(42)

```

```bash
python manage.py tinyjobs worker

```

What works today: queues, priorities, `run_after`, async tasks, `takes_context`, `get_result()`, and the `task_enqueued` / `task_started` / `task_finished` signals. `manage.py tinyjobs` also gives you `jobs`, `stats` and `check` for inspecting the queue and for health probes.

A few design choices you may care about:

- Tasks are resolved by import path, and only inside your `INSTALLED_APPS`, so a job can never make the worker import code your project doesn’t already trust.
- Arguments are JSON, as `django.tasks` expects; there’s no pickle.
- Delivery is at-least-once: if a worker dies mid-task, its lease expires and the task is marked `FAILED`, since Django tasks aren’t retried.
- The queue lives outside your database, so an enqueue can’t share your transaction. Use `transaction.on_commit`. If you need transactional enqueue through the ORM today, django-tasks-db is the better fit.

I tested it with a real project under uvicorn `--workers 2` and under `runserver`: 1,000 requests across sync and async views, each enqueuing a task that writes a row, with two workers on SQLite and then on Redis. Every task ran exactly once. Enqueueing through `django.tasks` costs about the same as calling tinyjobs directly, around 6,000 per second.

- Repo: [GitHub - Piergiuseppe/tinyjobs: Background jobs and cron for Python, on SQLite, with zero dependencies · GitHub](https://github.com/Piergiuseppe/tinyjobs)
- PyPI: `pip install tinyjobs` (zero dependencies, Python 3.12+)

I’d really appreciate feedback, especially from anyone who has been following `django.tasks`: what you’d expect from a backend, and anything that doesn’t feel Django-like.

---

<div class="post-metadata">

**Author:** ![Piergiuseppe](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/piergiuseppe/32/33611_2.png) [@Piergiuseppe](https://forum.djangoproject.com/u/Piergiuseppe)\
**Post date:** [November 3, 2026, 10:12am UTC](https://forum.djangoproject.com/t/tinyjobs-a-django-tasks-backend-and-worker-on-sqlite-postgres-or-redis/46293/2 "2026-11-03T10:12:56Z")

</div>

tinyjobs 0.8.0 is out, and it adds a Postgres backend, which is probably what most Django projects already run.

What changes for Django users:

- **Transactional enqueue.** With `"database": "default"` in `OPTIONS`, every enqueue joins that database’s transaction: a task enqueued inside `transaction.atomic()` exists only if the block commits, so no more `transaction.on_commit` wrappers. This corrects what I wrote above about enqueues not joining transactions; that still holds for SQLite and Redis.
- **No polling wait.** An idle worker is woken by `LISTEN`/`NOTIFY` and starts a new job in a few milliseconds.
- **Server clock.** Every machine keeps Postgres’ time, so workers on different machines don’t need their clocks to agree.
- Same backend contract as SQLite and Redis: queues, priorities, `run_after`, async tasks, `takes_context`, `get_result()` and the `task_*` signals all work, and switching is just the URL.

```python
TASKS = {
    "default": {
        "BACKEND": "tinyjobs.contrib.django.TinyJobsBackend",
        "OPTIONS": {"url": "postgresql://...", "database": "default"},
    }
}

```

Measured on Postgres 17 on a laptop: 20,000 jobs over four workers in 2.1 seconds, each run exactly once, and 6,850 enqueues a second from 24 threads. Twelve `SIGKILL`s on workers during 4,000 jobs, and three Postgres restarts during 6,000, left nothing lost and nothing run twice.

Feedback is still very welcome, especially from anyone already using `django.tasks` on Postgres.

---

<div class="post-metadata">

**Author:** ![Piergiuseppe](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/piergiuseppe/32/33611_2.png) [@Piergiuseppe](https://forum.djangoproject.com/u/Piergiuseppe)\
**Post date:** [November 4, 2026, 4:19pm UTC](https://forum.djangoproject.com/t/tinyjobs-a-django-tasks-backend-and-worker-on-sqlite-postgres-or-redis/46293/3 "2026-11-04T16:19:07Z")

</div>

tinyjobs 0.9.0 is out, and this one is about free-threaded Python.

On 3.14t the worker keeps the GIL off, so def tasks, which is what most Django tasks are, run in parallel in the worker’s thread pool. The worker also takes --loops N to run several event loops in threads inside one process, each with its own Postgres connection pool:

python manage.py tinyjobs worker --loops 3

Measured on a 4-core VPS against Postgres 17 (no CPU cap, async commits), draining 80,000 no-op def tasks: one process with 3 loops does 1,750 jobs/s with the GIL and 2,250 without, close to what 3 separate processes do (2,640 and 2,980), in a third of the memory. On tasks that burn about 1 ms of CPU each, the usual Django case, one process goes from 870 jobs/s with the GIL to 1,230 without, and adding loops with the GIL on makes it worse (500) while without it holds (1,190). Postgres itself took about 0.8 ms of CPU per job, more than twice what the worker spent, so on Postgres the store is the ceiling well before Python is; on Redis the same worker reaches 7,100 jobs/s.

loops works on Postgres and Redis; SQLite refuses it above 1, since its single writer would make the loops wait on each other, so run more processes there. Two install notes for 3.14t: psycopg-binary has no free-threaded wheels, so install psycopg psycopg-pool against the system libpq; and hiredis turns the GIL back on as soon as redis-py imports it, so leave it out (the worker logs a warning if it finds the GIL on).

Full numbers, with and without the GIL, in the README.

---

<div class="post-metadata">

**Author:** ![Piergiuseppe](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/piergiuseppe/32/33611_2.png) [@Piergiuseppe](https://forum.djangoproject.com/u/Piergiuseppe)\
**Post date:** [November 9, 2026, 3:50pm UTC](https://forum.djangoproject.com/t/tinyjobs-a-django-tasks-backend-and-worker-on-sqlite-postgres-or-redis/46293/4 "2026-11-09T15:50:50Z")

</div>

tinyjobs is at 0.15.0. Since 0.9.0 the worker gained a few things that matter for a Django project:

- Transactional enqueue on SQLite too (0.14). “database”: “default” in OPTIONS already made enqueues join the Postgres transaction; now it works on a SQLite alias as well, and the queue tables carry a tinyjobs\_ prefix so the queue can live in your project’s own SQLite file. A task enqueued inside transaction.atomic() exists only if the block commits.
- Per-task limits (0.15). concurrency=2 caps how many jobs of a task run at once across every worker; rate=“10/m” spaces its starts so no minute holds more than ten, which is what a quota towards an external API wants. The store enforces both at the claim, and a job a limit stops shows as held in manage.py tinyjobs stats and in the dashboard. For now these are declared on tinyjobs’ own @app.task; a way to set them on a django.tasks task is next on my list.
- Isolated tasks (0.10). isolated=True runs a task in a job process of its own, killed at its timeout and replaced when it crashes, so a C library or a memory leak cannot take the worker down. Same caveat about the Django decorator.
- Operations (0.11, 0.12). --log-format json with the job fields on every record, a Prometheus exporter on --metrics-port, manage.py tinyjobs check for health, and manage.py tinyjobs dashboard, a small read-only UI with the counts by queue and status, the waiting jobs by task and the job pages.
- Guarantees (0.13). A written list of what is promised on every backend, and tinyjobs verify, which kills workers under load against your own store and checks that nothing was lost and no side effect ran twice.

Numbers, on the same Redis and the same 4-core VPS, three worker processes each: 7,260 no-op jobs a second against Celery’s 800 with its default prefork pool; with about 1 ms of CPU per job, 840 against 610. The full tables and the ten-hour soak are in the docs.

Two upgrade notes: 0.14 renames the SQLite tables and 0.15 adds a status to every store, so stop every tinyjobs process before starting the first new one; an older process refuses to start against an upgraded store.

Docs: [https://tinyjobs.readthedocs.io/](https://tinyjobs.readthedocs.io/) — Limits: [https://tinyjobs.readthedocs.io/en/latest/limits/](https://tinyjobs.readthedocs.io/en/latest/limits/)

---

<div class="post-metadata">

**Author:** ![Piergiuseppe](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/piergiuseppe/32/33611_2.png) [@Piergiuseppe](https://forum.djangoproject.com/u/Piergiuseppe)\
**Post date:** [November 11, 2026, 9:30am UTC](https://forum.djangoproject.com/t/tinyjobs-a-django-tasks-backend-and-worker-on-sqlite-postgres-or-redis/46293/5 "2026-11-11T09:30:01Z")

</div>

tinyjobs 0.16.0 is out, and it is the release for people who use django.tasks.

Until now a django.tasks task on tinyjobs had a queue and a priority and nothing else. From 0.16 the rest goes on the same decorator:

```python
from django.tasks import task # on Django 6.0: from tinyjobs.contrib.django import task

@task(timeout=30, max_attempts=3)
def send_receipt(order_id): ...

@task(rate="10/m", concurrency=2)
def call_partner_api(order_id): ...

@task(isolated=True, timeout=120)
def render(document_id): ...

```

- timeout and retries (max\_attempts, retry\_on, backoff) per task
- concurrency= and rate= limits, counted in the store across every worker
- isolated=True runs the task in a process of its own, killed at the timeout
- the same options by import path in settings.TASKS, for tasks you do not own

Django 6.1 forwards the keywords to the backend’s task class, so it is Django’s own @task; on 6.0 tinyjobs ships the same decorator. A value that cannot be is an InvalidTask where the task is declared.

One behaviour change: task\_finished now fires once, from the worker, after the queue has recorded the outcome, so a receiver that reads the result finds it there.

Docs: [https://tinyjobs.readthedocs.io/django/](https://tinyjobs.readthedocs.io/django/)  
pip install -U tinyjobs

---

<div class="post-metadata">

**Author:** ![Piergiuseppe](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/piergiuseppe/32/33611_2.png) [@Piergiuseppe](https://forum.djangoproject.com/u/Piergiuseppe)\
**Post date:** [November 17, 2026, 3:50pm UTC](https://forum.djangoproject.com/t/tinyjobs-a-django-tasks-backend-and-worker-on-sqlite-postgres-or-redis/46293/6 "2026-11-17T15:50:18Z")

</div>

Three weeks in, this thread reads like a changelog, so here is a short picture of where tinyjobs stands today (0.19), for anyone landing here now.

**What it is.** A `django.tasks` backend with its own worker. The queue is a SQLite file, Postgres or Redis, and the task code is the same on all three.

**What a Django project gets**

- Django’s own `@task`, with `timeout`, retries, `rate=`, `concurrency=` and `isolated=True` on the decorator or in `settings.TASKS`.
- Transactional enqueue on Postgres and SQLite: with `"database": "default"` a task enqueued inside `transaction.atomic()` exists only if the block commits.
- `manage.py tinyjobs worker`, plus `stats`, `check`, a read-only dashboard, Prometheus metrics and JSON logs.

**New since 0.16**

- Tasks that run after another (0.17). The second waits until the first succeeds, and is cancelled if it fails for good:

- Upgrades without a stop (0.17 on). Processes of two neighbouring releases work on the same store, and every release is tested that way on all three backends.

- Moving to another store (0.19). `tinyjobs move --from sqlite:///jobs.db --to postgresql://...` carries the jobs still to run across, chains included, in any direction between the three.

- A compatibility page and a changelog (0.18): what is public, what a release may change, and what has to be true before 1.0.

- A fix for a rare case where a worker ignored a second Ctrl-C while a job blocked it (0.19).

One question for those who use `django.tasks`: it has no way to chain tasks, so I went with `task.after(result).enqueue(...)`, shaped like `.using()`. Does that read naturally to you, or would you expect something else?

I’ll leave this thread quiet until 1.0 unless there are questions.

Docs: [Django - tinyjobs](https://tinyjobs.readthedocs.io/en/latest/django/)  
Compatibility: [Compatibility - tinyjobs](https://tinyjobs.readthedocs.io/en/latest/compatibility/)
