Not everything should happen while the user waits. Sending emails, generating PDFs, importing spreadsheets and syncing with other systems are better done in the background. The patterns are simple, but the details decide whether jobs quietly fail.
Use a real queue
Put jobs on a durable queue, such as a managed message queue or a database-backed job library, and process them with workers you can scale separately from the web application. Avoid long jobs inside web requests, and in-memory timers that disappear with every deployment.
Make jobs safe to repeat
- Design every job to be idempotent, because it may run more than once
- Retry failures with backoff, and stop after a limit
- Move jobs that keep failing to a dead-letter queue for review
- Split large jobs into small batches that can resume after a crash
Scheduled work
For recurring tasks, use a scheduler that guarantees one run per interval across all servers, not a cron entry copied onto every machine. Record when each job last succeeded and alert if it has not run on time.
See what is happening
Track queue length, job duration, failures and the age of the oldest waiting job. Those four numbers reveal almost every background processing problem before users notice.
Our engineers and consultants write about what they see in real projects. Have a question about your own systems?






