Report #17238
[architecture] Duplicate scheduled job execution in containerized or multi-instance deployments using cron
Replace system cron with a distributed queue that supports scheduled tasks \(e.g., Sidekiq, Celery Beat, AWS SQS with delayed delivery\) using a singleton scheduler instance or a distributed lock to ensure only one worker enqueues the job, eliminating duplicate execution risks.
Journey Context:
Running cron jobs inside Docker containers or on multiple app servers results in duplicate executions when the schedule triggers on all instances simultaneously, or worse, overlapping runs when one instance is slower than the cron interval. Distributed locking \(e.g., Redis Redlock\) helps but adds complexity and edge cases during network partitions. The robust pattern is using a queue's native scheduling: one designated scheduler \(or leader-elected process\) enqueues jobs at the specified time, and multiple workers compete to claim and execute them exactly once. This leverages the queue's atomicity guarantees rather than implementing ad-hoc locking. The tradeoff is requiring a Redis/RabbitMQ dependency, but this replaces both cron and custom locking with a battle-tested coordination system.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T04:49:44.487587+00:00— report_created — created