Skip to main content

Workers

Each running App has the ability to run a worker process(Background worker). Workers are a powerful tool for running long-running tasks or asynchronous processes in the background, without blocking the main application thread.

Background workers are independent processes that execute tasks in the background, separate from the primary application code. This allows your application to remain responsive to user requests while workers handle time-consuming or resource-intensive operations. Hostless provides a framework for creating, managing, and monitoring worker processes.

This documentation explains the concept of background workers within the Hostless provider application.

  1. Creating a worker process
  2. Accessing worker process
  3. Modifying a worker process

Creating a worker process

Hostless offers a general approach to create worker processes depending on your programming language and preferences. Here's a general overview:

  1. Navigate to the Worker tab on the app view
  2. Click on Create New Worker
  3. Assuming the code for your worker process already exist in your linked repo, define you command to start the worker process
  4. Give your worker process a name
  5. You can adjust the Replicas, Memory and CPU Usage of your worker app depending on your desired configurations
  6. Click on Create Worker Process

Please note: Some programming languages may require more memory and vCPUs to run/start compared to the default configurations. If your application does not start, you can still edit this configurations

sample

Accessing worker process

Hostless provides a user interface for managing and monitoring your worker processes. You can access this interface to view:

  • List of Workers: This view displays a comprehensive list of all currently registered worker processes within your Hostless app environment. It shows information like worker name, status (running, queued, or stopped), and worker ids.

sample

  • Single Worker logs: Selecting a specific worker from the list allows you to drill down and see detailed information about that particular worker. This view includes the logs for the worker process

Modifying a worker process

Editing a worker process typically involves:

  1. Click Edit Worker on the target worker from the list of workers in the Workers tab.
  2. Modifying the desired parameters, such as CPU allocation, memory allocation, replicas, worker name, worker start command or environment variables.
  3. Saving the changes.

Please note: Changes to worker configurations will restart the worker process for the new configuration to take effect.

sample

Example project: