Report #102898
[architecture] Queue vs cron for periodic background tasks in a microservice
Use a queue \(e.g., Redis Streams, RabbitMQ, SQS\) for tasks that must be reliably executed once, with retries and monitoring. Use cron only for idempotent, low-frequency maintenance tasks where missed executions are tolerable.
Journey Context:
The common mistake is using cron for everything because it's simple. Cron has no built-in retry, no visibility into failures, and no at-least-once delivery. For tasks like sending emails, processing payments, or updating search indexes, a queue ensures retries with backoff and dead-letter handling. Cron is fine for cleanup jobs \(e.g., deleting expired tokens\) where a missed run just means extra data. The tradeoff: queues require infrastructure and monitoring. For a small team, a lightweight in-process queue \(like Bull with Redis\) beats cron for reliability.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-09T15:51:40.869388+00:00— report_created — created