Skip to main content
Workers are the backbone of Activepieces, responsible for executing workflows, processing triggers, and handling background tasks. This guide explains worker architecture and configuration.

What are Workers?

Workers are Node.js processes that:
  • Consume jobs from Redis queue (BullMQ)
  • Execute workflows using the execution engine
  • Poll external APIs for scheduled triggers
  • Renew webhooks for trigger subscriptions
  • Process async tasks (emails, notifications)
Workers are separate from the API server, allowing independent scaling based on workload.

Worker Architecture

Worker Process Lifecycle

Job Types

Workers process different job types from the queue:

1. ExecuteFlowJob

job
Purpose: Execute a workflow instanceTriggered by:
  • Webhooks
  • Manual runs
  • Scheduled triggers
  • Child flows
Data:
Processing:
  1. Load flow version from database
  2. Spawn execution engine
  3. Pass flow definition and payload
  4. Collect execution result
  5. Save flow run to database

2. PollingJob

job
Purpose: Poll external API for new dataTriggered by: Cron schedule (default: every 5 minutes)Data:
Processing:
  1. Load trigger configuration
  2. Call piece’s onEnable hook
  3. Fetch new items from API
  4. Deduplicate items
  5. Enqueue ExecuteFlowJob for each item

3. WebhookJob

job
Purpose: Process webhook payloadTriggered by: Incoming webhook HTTP requestData:
Processing:
  1. Validate webhook signature
  2. Transform payload if needed
  3. Enqueue ExecuteFlowJob

4. RenewWebhookJob

job
Purpose: Renew webhook subscriptionsTriggered by: Cron schedule (before expiration)Data:
Processing:
  1. Call piece’s renewal endpoint
  2. Update webhook registration
  3. Store new webhook URL/token

5. UserInteractionJob

job
Purpose: Handle human-in-the-loop tasksData:
Processing:
  1. Resume paused flow run
  2. Continue from approval step
  3. Complete execution

Worker Configuration

Container Type

Control what runs in each container:
Default: Both API and workers in one container
.env
Use for:
  • Development
  • Small deployments
  • Single-server setups
Implementation (from docker-entrypoint.sh):

Worker Concurrency

number
Number of jobs processed simultaneously per workerFormula:
  • CPU-bound workflows: concurrency = CPU cores
  • I/O-bound workflows: concurrency = CPU cores × 2-4
Examples:
Trade-offs:
  • Higher concurrency = more throughput
  • Higher concurrency = more memory usage
  • Too high = context switching overhead

Worker Token (Dedicated Workers)

string
Authentication token for dedicated worker deployments
.env
Used to authenticate worker API calls to main app.

BullMQ Integration

Activepieces uses BullMQ for job queue management.

Queue Structure

Location: app/workers/queue/queue-manager.ts Queue configuration:

Job Lifecycle

Job Priorities

Delayed Jobs

Repeating Jobs

Worker Scaling

Horizontal Scaling

Add more worker containers:
docker-compose.yml

Kubernetes Scaling

Auto-scaling Rules

Scale based on queue depth:

Monitoring Workers

Queue Metrics

Check queue health:

Queue UI

Enable BullMQ Board for visual monitoring:
.env
Access at: http://your-domain/admin/queues Features:
  • View waiting/active/failed jobs
  • Retry failed jobs
  • Remove jobs
  • View job data and stack traces
  • Queue statistics

Logs

Monitor worker logs:

Metrics API

Activepieces exposes queue metrics:
Response:

Performance Tuning

Redis Configuration

Optimize Redis for queue performance:
redis.conf

Worker Optimization

Increase Concurrency

For I/O-bound workflows:

Pre-warm Cache

Load pieces into memory on startup:

Adjust Timeouts

Increase for long-running workflows:

Resource Limits

Set Docker resource limits:

Error Handling

Retry Strategy

BullMQ retries failed jobs automatically:

Failed Job Retention

Configure how long to keep failed jobs:
.env

Dead Letter Queue

After max retries, jobs move to failed queue:

Best Practices

Use dedicated containers for production:Benefits:
  • Independent scaling
  • Resource optimization
  • Better fault isolation
  • Easier monitoring
Alert when queue grows:
Prevent memory leaks:
Visual debugging:

Troubleshooting

Symptoms: Jobs not processingCheck:
  1. Workers running: docker ps | grep worker
  2. Redis connection: redis-cli ping
  3. Worker logs for errors
Fix:
Symptoms: Workers consuming too much RAMCheck:
  1. Worker concurrency: AP_WORKER_CONCURRENCY
  2. Workflow complexity
  3. Memory leaks in custom code
Fix:
Symptoms: Many jobs in failed queueCheck:
  1. Failed job details in Queue UI
  2. Worker logs for stack traces
  3. External API availability
Fix:

Next Steps

Engine

Understand execution engine

Scaling

Scale workers horizontally

Architecture

System architecture overview

Monitoring

Setup monitoring and alerts