Message Queues

12 min read

Some work is slow, like sending an email or making an invoice. A message queue lets your app say "I will do it soon" and reply at once. Workers then finish the slow work in the background.

New words

Synchronous
You wait until the work is finished before you get a reply.
Asynchronous
You get a reply at once and the work finishes later.
Producer
The part of the app that adds a job to the queue.
Queue
A line of jobs. The first job in is the first job out.
Consumer (worker)
A program that takes jobs from the queue and does them.
Retry
Trying a failed job again after a short wait.
Dead-letter queue
A separate queue that keeps jobs that failed again and again.

What you will learn

  1. The problem: a busy dosa counter
  2. Synchronous and asynchronous work
  3. Producer, queue and consumer
  4. A sudden rush: the queue grows and nothing is lost
  5. Try it: the dosa counter in your browser
  6. When a job fails: retries and the dead-letter queue
  7. When not to use a queue
  8. Trade-offs
  9. In a real system
  10. Interview tip
  11. Key takeaways

10 quiz questions at the end.

Start this lesson

The full lesson, with interactive demos and the quiz, opens after you sign in with Google. It is free.

All lessons · Back to the roadmap