Skip to content
BENIBIX Learn

Background Job

Development🏗️ ArchitectureEvents and Messages

Also known as Background Worker, Async Job, Job Worker

Work an app hands off to run later, so the user does not have to wait.

Think of it like

It is like leaving a coat at the dry cleaner. You get a ticket now and the coat later.

Example

When Lucy sends in a video, the site says Processing and lets her keep browsing. A worker makes three smaller copies over the next two minutes.

Why it matters

Pages stay fast because slow work happens somewhere else. A burst of work waits in the queue instead of crashing the site.

Definition

A background job is work an app does later, outside the request a user is waiting on. The web app puts a job on a queue and replies at once. A separate worker process takes jobs off the queue and runs them. Sending email, shrinking photos and making reports are common jobs. If a job fails, the worker can try it again.
On the right, the queue and the worker: slow jobs run there, after the reply is sent.

Common mistake

Writing jobs that break when run twice. Workers retry failed jobs, so each job should be safe to run more than once.

Key takeaways

  1. 1
    Hand it off. Reply now, work later.
  2. 2
    Queue and worker. Jobs wait their turn.
  3. 3
    Safe to retry. Run twice, same result.