Background jobs fail. Networks blip, third-party APIs time out, and workers restart mid-task. The goal is not to avoid failure but to make jobs safe to retry.
Make every job idempotent
A job should produce the same result whether it runs once or five times. Guard side effects with a unique key before doing the work.
Tune retries and backoff
public $tries = 5;
public function backoff(): array
{
return [10, 30, 60, 120];
}Exponential backoff gives a flaky dependency time to recover instead of hammering it.
Reach for batches
When a unit of work fans out, Bus::batch() lets you track progress and run a callback only after every child job succeeds. It turns a pile of jobs into one observable operation.