logo

Background Job

A background job is any task that runs asynchronously, outside the main flow of your application. Instead of making users wait for slow operations, the work is deferred to a separate process that handles it independently.

Why Background Jobs?

Web applications have a limited window to respond to requests. If an operation takes longer than a few seconds, the user experience degrades — or worse, the request times out.

Background jobs solve this by:

  • Responding immediately to the user while work continues in the background
  • Handling failures with retries instead of showing error pages
  • Processing at scale by distributing work across multiple workers

Common Background Job Patterns

Fire and Forget

Send an email, log an event, or sync data without waiting for completion.

Delayed Execution

Schedule a job to run after a specific delay (e.g., send a reminder email in 24 hours).

Scheduled/Recurring

Run a job on a schedule using cron expressions (e.g., generate a daily report at 9 AM).

Callback/Webhook

Execute a long-running task and call a URL when complete (e.g., video transcoding).

Background Jobs in Serverless

Serverless platforms (Vercel, Netlify, AWS Lambda) enforce strict execution time limits — typically 10 seconds to 15 minutes. Jobs that exceed those limits need an external orchestration service like AsyncQueue for execution management, retries, and result storage.