Skip to content
Backend system design · about 40 minutes

Background job queue

Design a background job system for a web app. The app enqueues jobs such as sending email, resizing images and generating reports. Some jobs must run at a set time, some must not run twice, and some fail and need retries. Workers can crash at any moment, and the team needs to see what is stuck.

Ask first

  • How many jobs a second, and how long does a typical job take?
  • Which jobs are not safe to run twice, for example charging a card?
  • Do we need scheduled and recurring jobs, priorities, or jobs that depend on other jobs?
  • Can we use a managed queue, or must it run on our own database?
  • How quickly must a job start after it is enqueued?

The outline

Write your own outline for each part first.

The strong answer, the pitfalls and the follow-ups opens with a year in the app. What a year includes