Error Diagnostics // TraceLite Bench
GlitchTip Celery Worker Backlog During Event Spikes
When a frontend loop or bad deploy fires 50,000 errors in 10 minutes, unbounded Celery worker memory grows rapidly until the worker container is OOM-killed.
Measured GlitchTip & Sentry Telemetry
Without CELERY_WORKER_MAX_TASKS_PER_CHILD, Python worker forks retain parsed stacktrace frames, source map ASTs, and Django QuerySet caches across thousands of tasks. Each worker process drifts from 140 MB to 550+ MB during event spikes.
| Subsystem / Signal | Measured Footprint | Operational Impact |
|---|---|---|
| Unbounded Celery Worker (4 procs) | 1.9 - 3.4 GB RSS | Memory leak during sustained error bursts |
| Recycled Worker (max-tasks=500) | 480 - 920 MB RSS | Flat memory sawtooth under 10M+ spikes |
| Safe Prefetch Multiplier | PREFETCH=1 | Prevents 1 worker hoarding Redis tasks |
Step-by-Step Triage & Compose Remediation
- Inspect Redis queue depth: Check LLEN celery inside the Redis container to confirm backlog saturation.
- Set worker task recycling: Add CELERY_WORKER_MAX_TASKS_PER_CHILD=500 and CELERY_WORKER_PREFETCH_MULTIPLIER=1 to .env.
- Cap worker mem_limit: Set mem_limit on the worker service inside docker-compose.yml so Postgres never gets starved.
docker compose exec redis redis-cli LLEN celery # .env remediation: CELERY_WORKER_CONCURRENCY=4 CELERY_WORKER_PREFETCH_MULTIPLIER=1 CELERY_WORKER_MAX_TASKS_PER_CHILD=500
Diagnostic FAQ
How many Celery workers fit on a 4 GB GlitchTip VPS?
2 to 4 Celery workers fit comfortably inside a 4 GB node alongside PostgreSQL 16 and Redis 7.
Why does PREFETCH_MULTIPLIER=1 matter during spikes?
Default prefetch=4 locks multiple heavy source-map tasks onto one worker while idle workers sit empty.