How should Nest handle jobs and scheduled tasks?
Practice this questionWANT TO UNDERSTAND THE CONCEPT FIRST?Learn How should Nest handle jobs and scheduled tasks?
Definition:
A background job moves work out of the immediate request path, while a scheduled task starts work at a chosen time. Nest can integrate with queues and schedulers, but reliable execution still requires durable state and coordination. Multiple app instances can run the same schedule unless one owner or a distributed coordination mechanism is used.
Key points:
-
Send slow work to a queue and let workers process it.
-
Use retry limits, idempotency and failed-job monitoring.
-
With multiple app instances, coordinate scheduled jobs to avoid duplicate runs.
-
Acknowledge queue work only after its required state is durable; design retries for a worker crash after a side effect.
Interview point:
- Explain at-least-once delivery and idempotent handlers instead of claiming the queue guarantees one business effect automatically.
Adapted from 03_NESTJS.md · “How should Nest handle jobs and scheduled tasks?”. Code examples are study fragments. Difficulty and core labels are editorial estimates; version-specific behavior should be checked against your project.