NestJS · Senior · Question 30 of 75
What problem can a global @Cron cause in a scaled Nest deployment, and how do you solve it?
- 1Cron jobs don't run with more than one replica
- 2The job runs only on the oldest pod automatically
- ✓Correct answer: Every replica runs the job; use a distributed lock, a dedicated worker deployment or a queue's repeatable jobs
Explanation
Jobs should also be idempotent, because locks can expire and runs can overlap.