Django + Celery + Redis + PostgreSQL
Django web app with Celery workers, Redis as broker and cache, and PostgreSQL as the system of record, the standard way to move slow work out of Django requests.
- Django
- Celery
- Redis
- PostgreSQL
- Python
- Learning curve
- Moderate
- Status
- Mature and maintained
- Reviewed
- November 2026
- Best for
- Django apps that send email, generate files or call slow third-party APIs
- Scheduled jobs such as nightly syncs, digests and cleanup via Celery Beat
- Bulk imports and fan-out work split into many small tasks
- Teams already on Django who want background jobs without a second language
- Not ideal for
- Ordered event streaming with replay
Overview
This stack takes a Django + PostgreSQL app and adds Celery worker processes that pull jobs from Redis, so emails, report generation, imports, webhooks and scheduled jobs run outside the HTTP request. PostgreSQL stays the source of truth, Redis carries the task messages (and often doubles as the Django cache), and Celery Beat triggers periodic work. It is the default answer when a Django team first needs background jobs and cron-style scheduling.
What's inside
Writing a first task takes an afternoon. Running it reliably takes longer: transaction timing, idempotency, acknowledgement modes, prefetch, visibility timeouts and Beat deployment are where teams learn the hard way.
Django
Backend
Handles requests, business logic and APIs
Learning: Moderate
Status: Active
PostgreSQL
Database
Stores and queries the data
Learning: Moderate
Status: Active
Redis
Cache
Keeps frequently read data in memory
Learning: Easy
Status: Active
Python
Language
The language the code is written in
Learning: Easy
Status: Active
Celery
Other
Supporting tool
Learning: Hard
Status: Mature
How it works
A Django view writes to PostgreSQL and, once the transaction commits, publishes a task message to Redis. Separate Celery worker processes consume the message, load fresh rows from PostgreSQL by ID, do the slow work and record the outcome.
- 1.
Infrastructure to backend
Gunicorn or Uvicorn hands the HTTP request to a Django view, which validates input and opens a database transaction.
- 2.
Backend to database
The view writes the order, upload or user record to PostgreSQL and returns quickly instead of doing the slow work inline.
- 3.
Backend to cache
Inside transaction.on_commit, the view calls task.delay(record_id), which serialises a small JSON message onto a Redis list.
- 4.
Cache to other
A Celery worker reserves the message from Redis according to its prefetch setting and starts the task in one of its pool processes.
- 5.
Other to database
The task re-reads the row by ID through the Django ORM, performs the work (email, PDF, API call) and writes status back to PostgreSQL.
- 6.
Other to cache
The worker acknowledges the message and, if a result backend is enabled, stores the return value in Redis with an expiry.
Strengths and drawbacks
Strengths
Keeps requests fast
Slow work moves to workers, so a signup that sends a welcome email or a checkout that calls a payment webhook returns in milliseconds and retries happen off the request path.
Retries, rate limits and scheduling built in
Celery tasks support autoretry_for with exponential backoff, per-task rate limits, time limits, ETA/countdown scheduling and Beat for periodic jobs, so you do not hand-roll a job runner.
Same code, same ORM
Tasks are plain Python functions that import Django models and settings, so business logic is shared between views and workers and tested with the same tooling.
Workflow primitives
Canvas primitives (chain, group, chord) let you express fan-out/fan-in pipelines, such as processing every page of an import and then sending one summary.
Independent scaling of workers
Worker pools scale separately from web processes and can be split by queue, so a burst of image processing does not starve password-reset emails.
Drawbacks
Enqueue-before-commit race
Calling .delay() inside an open transaction lets a fast worker look up a row that is not committed yet, or act on a write that later rolls back. Wrap enqueues in transaction.on_commit and pass IDs, not model instances.
At-least-once delivery means idempotent tasks
With acks_late or after a worker crash, tasks can run twice. With the Redis broker, an unacknowledged task is redelivered after visibility_timeout (one hour by default), which also bites long ETA/countdown tasks. Design tasks to be safe to repeat.
More moving parts to operate
You now run web processes, workers, a single Beat scheduler and Redis, each needing monitoring (Flower, queue-length alerts), deploy ordering and graceful shutdown. Running two Beat instances duplicates every scheduled job.
Redis memory and licensing
Redis keeps queues and stored results in RAM, so a stuck worker or unexpired results can fill memory. Redis 7.4 moved to source-available licences and Redis 8 added AGPLv3; teams that need a BSD-licensed broker often use Valkey, which speaks the same protocol.
Prefetch and long tasks
By default each worker process prefetches several messages, so one long task can hold others hostage on a busy worker. Long-running queues usually need worker_prefetch_multiplier=1 and acks_late.
Scores
Editorial ratings out of 10, comparable across every stack in the guide. They are judgement, not benchmarks. How we score
- Speed of building
- 7.8 out of 10, catalog average 7.7
- Ease of learning
- 6.8 out of 10, catalog average 7.2
- Scalability
- 8.0 out of 10, catalog average 7.6
- Performance
- 7.0 out of 10, catalog average 7.5
- Maintainability
- 7.2 out of 10, catalog average 7.2
- Ecosystem
- 9.0 out of 10, catalog average 8.2
- Flexibility
- 7.6 out of 10, catalog average 7.4
How quickly a team ships features
Higher means easier to pick up
How far it grows before a redesign
Speed of the running application
How well the codebase ages
Libraries, hosting, docs and hiring
How many kinds of product it suits
How it scales
Web and worker tiers scale independently; Redis and PostgreSQL connection limits are usually the first ceilings, followed by queue isolation and broker choice.
- Starting outMVP and first users
- One VM or PaaS app running Gunicorn, a single Celery worker with Beat embedded (-B), a small Redis and managed PostgreSQL.
- GrowingReal traffic, a few engineers
- Separate web and worker containers, a dedicated Beat process, named queues per workload, PgBouncer in front of PostgreSQL and Flower or Prometheus metrics on queue depth.
- LargeHeavy traffic or data
- Autoscaled worker pools per queue (for example on queue length with KEDA), Redis with replication or a managed equivalent, PostgreSQL read replicas for reporting tasks.
- EnterpriseMany teams and regions
- High-volume or routing-heavy queues move to RabbitMQ quorum queues or an event bus like Kafka, with Celery kept for job-style work and strict per-queue SLOs and dead-letter handling.
Where it fits
Common projects, from best fit to worst.
Transactional email and notifications
Signup, receipt and password-reset messages are queued on commit and retried with backoff when the email provider is slow or down.
Great fit
Report, export and media generation
CSV exports, PDF invoices and image thumbnails run in workers and write a status row users can poll, instead of timing out a request.
Great fit
Nightly syncs and scheduled maintenance
Celery Beat triggers partner-API syncs, digest emails and data cleanup; a single Beat instance and idempotent tasks are required.
Good fit
Ordered event streaming with replay
Celery does not guarantee ordering across workers or keep consumed messages, so audit logs, CDC pipelines and multi-consumer event streams fit Kafka better.
Poor fit
Alternatives
Similar stacks, and when you would choose them instead.
- Django + PostgreSQL
Pick plain Django + PostgreSQL when background work is light enough for a database-backed queue or Django's own tasks API, avoiding Redis and a separate worker fleet.
CompareDjango + Celery + Redis + PostgreSQL with Django + PostgreSQL - RabbitMQ + Python
Pick RabbitMQ directly when you need explicit exchanges, routing keys, dead-lettering and quorum-queue durability between services rather than a Django job runner.
CompareDjango + Celery + Redis + PostgreSQL with RabbitMQ + Python - Apache Kafka + Python
Pick Kafka when work is a stream of events that several consumers must read and replay, not one-off jobs that disappear once done.
CompareDjango + Celery + Redis + PostgreSQL with Apache Kafka + Python - Rails + PostgreSQL
Rails 8 ships Solid Queue, which keeps jobs in the relational database, for teams that want background jobs without running Redis.
CompareDjango + Celery + Redis + PostgreSQL with Rails + PostgreSQL
Sources
Reviewed on November 19, 2026 against the documentation below. Found something out of date? Suggest a correction. Read our methodology.
- Celery: First steps with Django
Official Celery guide for wiring a Celery app into a Django project.
- Celery: Using Redis
Official Redis broker notes, including the visibility timeout caveat.
- Django: PostgreSQL notes
Official Django PostgreSQL notes.
- Django: Database transactions
Covers transaction.on_commit, used to enqueue tasks only after data is committed.
Related stacks
Stacks that share technologies with Django + Celery + Redis + PostgreSQL.
FastAPI + PostgreSQL
FastAPI API services with PostgreSQL, a high-adoption Python API stack for microservices and ML-adjacent backends.
- FastAPI
- Python
- PostgreSQL
- +1
Learning: Easy
FastAPI + SQLAlchemy + PostgreSQL
FastAPI with the SQLAlchemy 2.0 ORM, Alembic migrations and PostgreSQL, the Python API stack for teams that want a full unit-of-work ORM behind typed endpoints.
- FastAPI
- SQLAlchemy
- PostgreSQL
- +2
Learning: Moderate
Flask + PostgreSQL
Flask microframework with PostgreSQL, usually through Flask-SQLAlchemy and Flask-Migrate, a long-standing lightweight Python stack for small web apps, internal tools and APIs.
- Flask
- Python
- PostgreSQL
Learning: Easy