← Lessons

quiz vs the machine

Gold1430

System Design

The Visibility Timeout

Hide an in flight job so two workers never process it at once.

5 min read · core · beat Gold to climb

In Flight But Not Lost

When a worker receives a job it does not delete it yet. The broker hides the job for a visibility timeout window. During that window other workers cannot see it. The worker must finish and acknowledge before the window expires.

The Two Outcomes

  • Worker finishes in time and acknowledges, so the broker deletes the job.
  • Window expires first so the broker assumes the worker died and makes the job visible again for another worker.

This is how a crashed worker does not strand a job, while a live worker keeps exclusivity.

Choosing the Window

  • Too short and a slow but healthy worker loses its job mid run, causing duplicate processing.
  • Too long and a truly dead worker holds the job idle, delaying recovery.

Set the window above the realistic worst case duration for that job type.

Heartbeat Extension

For long or variable jobs, a worker can extend the timeout periodically while it makes progress. This avoids setting one huge static window and lets stuck jobs still time out.

Key idea

The visibility timeout hides an in flight job so only one worker holds it, and redelivers if the worker fails to finish in time.

Check yourself

Answer to earn rating on the learn ladder.

1. What happens when a visibility timeout expires before the worker acknowledges?

2. What is the risk of setting the visibility timeout too short?

3. How can a long running job avoid a huge static timeout?