Report #48826
[architecture] When to use message queues instead of cron jobs for background processing
Use message queues \(SQS, RabbitMQ, Celery\) for event-driven, scalable processing where latency matters; use cron only for true time-based scheduling \(daily reports, data retention cleanup\) where the requirement is 'run at time X', not 'run after event Y'. Never use cron to poll for work.
Journey Context:
Developers abuse cron to poll for work \(e.g., 'every minute check for new emails'\), creating inherent latency \(up to the polling interval\), wasted CPU cycles on empty checks, and race conditions when the job duration exceeds the interval. Message queues provide immediate, push-based consumption with built-in retry, dead-letter handling, and horizontal scaling. The exception is true time-based logic \(e.g., 'send daily digest at 9 AM' or 'purge logs every Sunday'\) where cron is semantically correct. The anti-pattern is 'cron as a poor man's queue'—if your cron expression is '\* \* \* \* \*' or you are checking 'if new\_records exist', switch to a queue.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T12:26:12.896640+00:00— report_created — created