A background worker is a process that runs in the background, separate from the main application. This type of process is useful for long-running processes like generating reports or processing large data sets. Keeping these separate from the main application helps to maintain a good user experience.
You can add a background worker when you add an application or at any time in Processes. While there is no limit to the number of background worker processes you can add, each process requires at least one pod to run.
To add a new background worker, click Create process and complete the fields as follows:
- Name: The process name; for example, Price calculation.
- Type: Choose Background worker.
- Start command: The command required to start the process, for example, npm run [process].
- Pod size: This determines the CPU and RAM dedicated to the process.
- Instances: The number of instances required, up to a maximum of 50. Each instance represents one pod, and the instances all use the same pod size. You cannot define a different pod size for each instance.
You can change the details of any process at any time, including the pod size (vertical scaling) and the number of pods running simultaneously (horizontal scaling). To learn more about changing pod size and other scaling options, see our guide on how to Scale Application Resources.