โ Backend Performance & Scaling learning pathBackend Performance & Scaling ยท Module 5 of 8
Asynchronous work and queues
Do slow work later, outside the request.
๐ Key ideas
- Users should not wait for slow work such as sending email, making PDFs or resizing images.
- Put the job in a queue and return quickly; background workers process the queue.
- Jobs should be idempotent: running the same job twice gives the same result.
- Retries with exponential backoff handle temporary failures without hammering the system.
- Failed jobs go to a dead-letter queue so they can be inspected instead of lost.
๐ก Real-life example: A queue is like a token system at a bank: you get a token immediately and can sit down, and the counters serve tokens in order as they become free.
QueueList of jobs waiting to be processed
WorkerProcess that takes jobs from a queue and runs them
IdempotentSafe to run more than once with the same result
Dead-letter queuePlace for jobs that keep failing