Benefits of separating workers from the main application (APP):

  • Availability: The application remains lightweight, allowing workers to be scaled independently.
  • Security: Workers lack direct access to Redis and the database, minimizing impact in case of a security breach.
1

Create Worker Token

Create a worker token by executing npm run workers token at the root of the repository. You will be prompted to enter a JWT secret (Same as AP_JWT_SECRET used for the app server), after which the token will be generated.

2

Configure Environment Variables

Define the following environment variables in the .env file on the worker machine:

  • Set AP_CONTAINER_TYPE to WORKER
  • Specify AP_FRONTEND_URL
  • Provide AP_WORKER_TOKEN
3

Configure Persistent Volume

Configure a persistent volume for the worker to cache flows and pieces. This is important as first uncached execution of pieces and flows are very slow. Having a persistent volume significantly improves execution speed.

Add the following volume mapping to your docker configuration:

volumes:
  - <your path>:/usr/src/app/cache
4

Launch Worker Machine

Launch the worker machine and supply it with the generated token.

5

Verify Worker Operation

Verify that the workers are visible in the Platform Admin Console under Infra -> Workers.

6

Configure App Container Type

On the APP machine, set AP_CONTAINER_TYPE to APP.