---
title: "Background work"
description: "Which tool runs work outside a request, from Convex's scheduler and crons to the official workflow, workpool, action cache and migrations components, and what the backend component already runs on its own."
canonical_url: "https://nuxt-backend.dev/docs/build/data/jobs"
---
# Background work

> Which tool runs work outside a request, from Convex's scheduler and crons to the official workflow, workpool, action cache and migrations components, and what the backend component already runs on its own.

Version: nuxt-backend 0.6.x · Tab: Build · Kind: concept · Status: stable

Every page: [llms.txt](https://nuxt-backend.dev/llms.txt) · Skill for coding agents: [nuxt-backend](https://nuxt-backend.dev/.well-known/skills/nuxt-backend/SKILL.md)

Commands use npm; use your project's package manager.

A query or a mutation answers one call and is done. Work that happens later, on a clock, over several steps or in bulk runs in the background, on Convex's own scheduler or an official Convex component. Your app uses them directly, the way their docs show: the package wraps only workflows, and keeps its own maintenance inside its component.

## Which tool when

<table>
<thead>
  <tr>
    <th>
      You want to
    </th>
    
    <th>
      Use
    </th>
    
    <th>
      Page
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      Run one function later: in a minute, or at a set time
    </td>
    
    <td>
      <code>
        ctx.scheduler.runAfter
      </code>
      
       or <code>
        runAt
      </code>
      
      , in any mutation or action
    </td>
    
    <td>
      <a href="https://docs.convex.dev/scheduling/scheduled-functions" rel="nofollow">
        Convex scheduling
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      Run a job on a fixed schedule
    </td>
    
    <td>
      <code>
        cronJobs()
      </code>
      
       in <code>
        backend/crons.ts
      </code>
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/build/data/jobs/scheduled#your-own-jobs">
        Schedule jobs
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      Run a job on a schedule your code picks, such as a digest at each reader's hour
    </td>
    
    <td>
      The <a href="https://www.convex.dev/components/crons" rel="nofollow">
        <code>
          @convex-dev/crons
        </code>
      </a>
      
       component
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/build/data/jobs/scheduled#jobs-your-code-schedules">
        Schedule jobs
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      Delete rows once they pass an age
    </td>
    
    <td>
      <code>
        defineRetention
      </code>
      
      , started from <code>
        crons.ts
      </code>
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/build/data/retention">
        Delete old data on a schedule
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      Run several steps over minutes or days, each retried, surviving restarts
    </td>
    
    <td>
      A workflow, through <code>
        setupWorkflows
      </code>
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/build/data/jobs/workflows">
        Run a durable workflow
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      Run many of the same job a few at a time, with retries and a callback
    </td>
    
    <td>
      The <a href="https://www.convex.dev/components/workpool" rel="nofollow">
        <code>
          @convex-dev/workpool
        </code>
      </a>
      
       component
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/build/data/jobs/workpool">
        Queue work with a workpool
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      Keep an expensive action's results, so the same call runs once
    </td>
    
    <td>
      The <a href="https://www.convex.dev/components/action-cache" rel="nofollow">
        <code>
          @convex-dev/action-cache
        </code>
      </a>
      
       component
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/build/data/jobs/action-cache">
        Cache expensive actions
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      Change existing documents in batches
    </td>
    
    <td>
      The <a href="https://www.convex.dev/components/migrations" rel="nofollow">
        <code>
          @convex-dev/migrations
        </code>
      </a>
      
       component
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/build/data/jobs/migrations">
        Migrate data
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      Queue AI generations, with what each plan gets in line and credits held until they run
    </td>
    
    <td>
      <code>
        defineJobQueue
      </code>
      
      , in the <code>
        ai
      </code>
      
       capability
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/build/ai/jobs">
        Run generation jobs
      </a>
    </td>
  </tr>
</tbody>
</table>

Pick the scheduler for one delayed call, and a cron when the same thing repeats on a clock. Pick a workflow when one piece of work has several steps that must all happen, and a workpool when there is a lot of the same work that must not all run at once. Put the action cache in front of an action called again with the same arguments.

## What the component already runs

The `backend` component cleans up after itself. Its own cron starts a maintenance pass every hour, wherever the component is mounted, so your app schedules nothing for it. A pass deletes what is past its window in the component's own tables: expired sessions and codes, settled AI request records, old email records, unanswered invitations, activity past its year, old exports and failed erasures. It also deletes uploads nobody claimed ([Keep storage clean](https://nuxt-backend.dev/docs/build/data/files/cleanup)).

[Schedule jobs](https://nuxt-backend.dev/docs/build/data/jobs/scheduled#the-maintenance-the-component-runs) names each task and how a pass runs. [Limits and retention](https://nuxt-backend.dev/docs/reference/backend/limits#windows-and-lifetimes) gives every window. A sign-in code takes its own path from the start and [leaves no record](https://nuxt-backend.dev/docs/build/email/sending#secret-emails-leave-no-record).

## What this means for you

- **Schedule nothing for the package.** Mounting the `backend` component is enough, on every deployment, previews included.
- **Keep your own tables small yourself.** The component never reads or deletes your data: give each table that grows a [retention rule](https://nuxt-backend.dev/docs/build/data/retention).
- **Install a component when you first need it.** The scaffold mounts `workflow` and `workpool`, which the package's own helpers use. Mount the crons, action cache and migrations components yourself, as their pages show.
- **Know your plan's limits.** Scheduled functions and crons count as function calls on your Convex plan ([Convex](https://nuxt-backend.dev/docs/services/convex#costs-and-limits)).
- **Watch the passes** on the DevTools [Overview tab](https://nuxt-backend.dev/docs/develop/devtools#overview), or with `npx convex run --component backend maintenance:status`.


## Sitemap

See the full [sitemap](https://nuxt-backend.dev/sitemap.md) for all pages.
