โ† Backend Performance & Scaling learning path
Backend Performance & Scaling ยท Module 5 of 8

Asynchronous work and queues

Do slow work later, outside the request.

๐Ÿ“– Key ideas

  1. Users should not wait for slow work such as sending email, making PDFs or resizing images.
  2. Put the job in a queue and return quickly; background workers process the queue.
  3. Jobs should be idempotent: running the same job twice gives the same result.
  4. Retries with exponential backoff handle temporary failures without hammering the system.
  5. 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