Work outside the request.
WHAT TO MOVE TO A QUEUE
Sending mail Processing images and files Calling external services Generating reports Anything slow
WHY
Requests should return quickly, and slow work risks timing out.
WHAT A QUEUE WORKER IS
A long-running process consuming jobs.
WHAT THAT REQUIRES
The ability to run persistent processes.
WHAT TO DO WHERE THAT IS UNAVAILABLE
Process the queue on a schedule instead.
WHAT TO CONFIGURE
Retry attempts Increasing delay between attempts Handling of permanently failed jobs
WHAT TO ENSURE
That every job is safe to run twice.
WHY
Retries occur, and duplicates otherwise result.
WHAT TO REMEMBER ABOUT WORKERS
They hold code in memory, and must be restarted after deployment.
WHAT THAT CAUSES WHEN FORGOTTEN
Old code running indefinitely after a release.
WHAT SCHEDULING REQUIRES
A single system entry invoking the scheduler each minute.
WHAT TO PREVENT
Overlapping runs of long tasks.
WHAT TO MONITOR
Failed jobs, queue depth, and whether workers are running.