# Background work

This page covers the work your app does outside a request: schedules that
run an action on a timer, events an action announces, subscribers that
react to them, and what happens when that work fails.

Three things start work, and each one calls an ordinary
[action](/docs/functions-and-actions.md), the kind of function that
reads and writes stored records:

| Trigger | Starts when | Lives in |
|---|---|---|
| Route | A request arrives | `routes/` ([HTTP](/docs/http.md)) |
| Schedule | A timer fires | `schedules/` |
| Subscriber | An event it listens for is committed | `subscribers/` |

All your logic lives in actions, so a reviewer reads one kind of code
whatever started it. A schedule or a subscriber only adds *when* to run
and *what happens if it fails*.

Two more things feed this work without being triggers of their own:

- Work over more items than one action can hold runs as a **batch**. An
  action starts it, and it calls an action for each item
  ([Batches](/docs/batches-work-over-many-items.md)).
- The outside world produces events for your subscribers: webhooks, a
  package's own events and polls, and messages read from a queue
  ([Events from outside](/docs/events-from-outside.md)).

Much of this page talks about the **tick**. The tick is the runtime's
regular wake-up, once a minute in most apps: it runs the schedules that
are due and picks up background work left over
([The tick](/docs/schedules.md#the-tick)).

| Page | What it covers |
|---|---|
| [Schedules](/docs/schedules.md) | Use a schedule for work that should happen on a timer rather than when someone asks, such as sending reminders every 15 minutes or tidying up once a day. |
| [Batches](/docs/batches-work-over-many-items.md) ▲ partly | Use a batch when one action can't hold the work: importing every row of an uploaded spreadsheet, writing a large export, or walking every record a query finds or every page of a provider's list. |
| [Events](/docs/background-events.md) | How one part of an app tells the others that something happened: declaring an event, emitting it and subscribing to it. |
| [Delivery and failure](/docs/delivery-and-failure.md) | How an event reaches its subscribers, what happens when a subscriber fails, and what the person running the app sees. |

[What is built](/docs/jobs-and-events-built.md) says which of this works today.
