# Run background tasks

Run work outside a request to your web application. Choose a service for a continuous worker or a job for a task that ends.

> [!note] Requirements
>
> You will need the following to get started:
>
> - A container image or build source for the task
> - The command that starts the worker or task
> - Connection details for its database, queue, or external resources

### 1. Choose the workload type

| Process | Resource | Configuration guide |
| --- | --- | --- |
| Continues to consume work from a queue | Service | [Run an image continuously](https://northflank.com/docs/v1/application/run/run-an-image-continuously) |
| Performs a task and exits | Manual job | [Run an image once](https://northflank.com/docs/v1/application/run/run-an-image-once-or-on-a-schedule) |
| Performs a task at regular times | Scheduled job | [Run an image on a schedule](https://northflank.com/docs/v1/application/run/run-an-image-once-or-on-a-schedule) |

A continuous worker must keep its process running while it waits for work. A job command must finish when its task is complete.

### 2. Configure the workload

Create the selected resource and choose its image. If the image starts a web server by default, [override the command](https://northflank.com/docs/v1/application/run/override-command-entrypoint) with the task command.

Add the required [runtime variables](https://northflank.com/docs/v1/application/run/inject-runtime-variables) and [secrets](https://northflank.com/docs/v1/application/secure/inject-secrets). If the task uses a Northflank database, [link the database credentials](https://northflank.com/docs/v1/application/databases-and-persistence/connect-database-secrets-to-workloads).

Make sure that the workload can access each required resource before enabling a schedule or adding workers.

### 3. Define execution behavior

For jobs, review the schedule, concurrency policy, retry limit, and time limit in the [job guide](https://northflank.com/docs/v1/application/run/run-an-image-once-or-on-a-schedule). Choose values that fit the task duration and its handling of repeated work.

For a continuous worker, choose its [CPU and memory](https://northflank.com/docs/v1/application/scale/scale-cpu-and-memory) and [instance count](https://northflank.com/docs/v1/application/scale/scale-instances). Before adding instances, make sure that multiple workers can process the queue safely.

### 4. Observe the result

Run a test task and examine its [logs](https://northflank.com/docs/v1/application/observe/view-logs). Make sure that the expected application result exists. A process exit or a running container alone does not establish that the application work succeeded.

For tasks that form part of a release, use a [workflow](https://northflank.com/docs/v1/application/release/configure-workflows). For schema changes, read [Run migrations](https://northflank.com/docs/v1/application/release/run-migrations).
