# Setting CONN\_MAX\_AGE made my Django task workers 3 to 4x faster

**URL:** <https://forum.djangoproject.com/t/setting-conn-max-age-made-my-django-task-workers-3-to-4x-faster/46201>\
**Category:** Using Django\
**Created:** [October 17, 2026, 11:47am UTC](https://forum.djangoproject.com/t/setting-conn-max-age-made-my-django-task-workers-3-to-4x-faster/46201 "2026-10-17T11:47:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PhiLily](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/philily/32/33130_2.png) [@PhiLily](https://forum.djangoproject.com/u/PhiLily)\
**Post date:** [October 17, 2026, 11:47am UTC](https://forum.djangoproject.com/t/setting-conn-max-age-made-my-django-task-workers-3-to-4x-faster/46201/1 "2026-10-17T11:47:22Z")

</div>

I’ve been benchmarking database-backed task workers and found something worth sharing whichever backend you use.

With Django’s default `CONN_MAX_AGE = 0`, a worker closes its database connection after every task, so every task opens a new PostgreSQL connection. In my runs that cost about 5 ms each, more than the claim-and-run path takes on a warm connection.

Four workers, 20,000 no-op tasks, PostgreSQL 16 in Docker on the same host, django-ox 1.9.0 and django-tasks-db 0.13.0, medians of five runs:

- `CONN_MAX_AGE = 0`: 430 tasks a second on django-ox, 373 on django-tasks-db
- `CONN_MAX_AGE = 600`: 1,771 and 1,211
- psycopg pool via `OPTIONS["pool"]`: 1,718 and 1,216

Holding the connection is about a 4x change for django-ox and 3x for django-tasks-db. Django 6.0 rejects a pool combined with a nonzero `CONN_MAX_AGE`, so pick one. If your worker runs the default, that’s the first thing I’d change before adding more processes.

Both backends got identical connection settings. With a pool or persistent connections, django-ox did 1.4 to 1.7 times the tasks per second of django-tasks-db. These tasks do nothing, so real tasks that spend their time in your code will narrow the gap. Settings and every raw number: [Benchmarks - django-ox](https://oxpull.com/django-ox/benchmarks/)

django-ox is 100% open source (BSD-3-Clause) with no paid tier. Outside contributors have merged fixes, and pull requests are welcome: [django-ox/CONTRIBUTING.md at main · oxpull/django-ox · GitHub](https://github.com/oxpull/django-ox/blob/main/CONTRIBUTING.md)

If you get different numbers on your own hardware, I’d like to see them.

---

<div class="post-metadata">

**Author:** ![discourse\_ai\_spam](https://avatars.discourse-cdn.com/v4/letter/d/c68b51/32.png) [@discourse\_ai\_spam](https://forum.djangoproject.com/u/discourse_ai_spam)\
**Post date:** [October 17, 2026, 11:47am UTC](https://forum.djangoproject.com/t/setting-conn-max-age-made-my-django-task-workers-3-to-4x-faster/46201/2 "2026-10-17T11:47:26Z")

</div>

Unlisted on October 17, 2026, 11:47am UTC



---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/1X/43aa234ca0bf7c581b054b0ebee4abe7514a6808.png) [@system](https://forum.djangoproject.com/u/system)\
**Post date:** [October 17, 2026, 11:49am UTC](https://forum.djangoproject.com/t/setting-conn-max-age-made-my-django-task-workers-3-to-4x-faster/46201/3 "2026-10-17T11:49:48Z")

</div>

Listed on October 17, 2026, 11:49am UTC


