Django + PostgreSQL + Redis + Celery
Production guidelines for Django 6 enterprise applications, PostgreSQL connection pooling, Redis caching, and Celery async workers.
- Formats
- 4 files
- AGENTS.md
- 79 lines
- CLAUDE.md
- 16 lines
- Languages
- Python
- Updated
- Oct 2026
- Used by
- 4 projects
Writes .claude/skills/django-postgres-redis/SKILL.md
$ curl -s --create-dirs -o .claude/skills/django-postgres-redis/SKILL.md https://stackitfast.com/rules/django-postgres-redis/SKILL.mdRule files
Works with Cursor · Claude Code · Windsurf · AGY
Architecture notes
Architecture Overview
Production conventions for high-throughput, enterprise-scale Python backends using Django, PostgreSQL, Redis, and Celery.
Verified Real-World Adoption
This architecture powers heavy, analytics-intensive platforms including PostHog, Sentry, Plane, Baserow, and Authentik.
Key Architectural Nuances
- Calculated Connection Sizing: Balances Gunicorn web workers and Celery background processes against PgBouncer pool limits.
- Idempotent Queue Execution: Enforces
CELERY_TASK_ACKS_LATEwith atomic database transactions.
Frequently asked questions
Does this AGENTS.md work with Cursor, Claude Code, and Windsurf?
Yes — AGENTS.md is the open, cross-tool standard read by Cursor, Claude Code, Windsurf, GitHub Copilot, and 30+ other agents. A dedicated .mdc file is also included for Cursor's native .cursor/rules format.
Why must CONN_MAX_AGE be 0 when using PgBouncer?
PgBouncer in transaction-pooling mode already manages a persistent pool of real Postgres connections behind the scenes. If Django also holds connections open (CONN_MAX_AGE > 0), you get two overlapping pooling layers fighting for the same backend connections, which quickly exhausts Postgres's max_connections under load.
Why pass model IDs instead of model instances to Celery tasks?
Celery serializes task arguments and can execute them seconds or minutes later. A serialized model instance is a stale snapshot the moment it's queued, so any changes made before the task runs are silently lost. Passing the primary key and re-fetching inside the task guarantees the worker always operates on current data.
Used in production
Explore all stacksGlitchTip
Lightweight Sentry-compatible application performance monitoring and error tracking platform. Built on Python Django and PostgreSQL with async Celery task queues for high-volume exception ingestion and Redis message buffering.
Authentik
Replacing Redis with three purpose-built PostgreSQL-backed packages for channels, cache, and task queueing shrinks the required external dependencies to just PostgreSQL, while protocol proxying is pushed into separate Go outposts instead of the main Django process.
Baserow
A Django/PostgreSQL core with Nuxt/Vue frontend layers lets Baserow add premium and enterprise features as separate installable packages on top of one open-source base, while Channels and Celery keep realtime sync and background work inside the same deployable unit.
Sentry
Pairing Django with Kafka and ClickHouse allows Sentry to ingest billions of events daily while providing sub-second analytical search across production traces.