← Back to blog timeline

Production Django Task Queue

Building a ~300 LOC task queue on Django ORM from prototype to production — memory leaks, fork pitfalls, pessimistic locking, and security hardening.

  1. django-simple-queue: 300 Lines to Replace Celery

    How a ~300 LOC task queue built on Django ORM replaces Celery for small teams — the architecture, the tradeoffs, and when it makes sense.

  2. Hunting Memory Leaks in a Django Task Worker

    Production memory climbing to 500 MB. The fix: run tasks in subprocesses so the OS reclaims everything. From 500 MB to 50 MB.

  3. The Fork Bug and the Deploy Bug

    Two production bugs found in one debugging session: a database connection shared across fork(), and a deploy script that deleted the directory out from under a running worker.

  4. Pessimistic Locking: One Task, One Worker

    Using SELECT FOR UPDATE SKIP LOCKED to prevent multiple workers from claiming the same task — database-level concurrency without application-level locks.

  5. From Bug Fix to Production Hardening: A Refactoring Marathon

    Stalled task detection, security hardening, code refactoring, and lifecycle signals — turning a task queue into production-grade infrastructure.