Skip to main content
As your workflow automation needs grow, you can scale Activepieces to handle more concurrent executions and higher throughput. This guide covers horizontal scaling strategies.

Scaling Architecture

Activepieces can be scaled by separating concerns into specialized containers:

Container Types

Activepieces supports three container types via the AP_CONTAINER_TYPE environment variable:
All-in-one containerRuns both API server and background workers:
Use for:
  • Development
  • Small deployments (< 100 workflows)
  • Single server setups
Pros:
  • Simple configuration
  • Minimal resource overhead
Cons:
  • Limited scalability
  • API and workers compete for resources

Horizontal Scaling Strategies

Strategy 1: Multiple All-in-One Instances

Simple scaling - Run multiple WORKER_AND_APP containers:
docker-compose.yml
Nginx load balancer:
nginx.conf

Strategy 2: Separate APP and WORKER Containers

Recommended for production - Dedicated containers:
docker-compose.yml
Benefits:
  • Scale API and workers independently
  • Optimize resource allocation
  • Better fault isolation
  • Easier monitoring

Kubernetes Scaling

Horizontal Pod Autoscaler

Automatically scale based on CPU/memory:

Helm Configuration

values.yaml

Worker Configuration

Worker Concurrency

Control how many jobs each worker processes simultaneously:
.env
number
Guidelines:
  • CPU-bound workflows: concurrency = CPU cores
  • I/O-bound workflows: concurrency = CPU cores × 2-4
  • Default: 1 (safe default)
Example calculations:
  • 2 CPU cores, CPU-intensive: concurrency = 2
  • 4 CPU cores, API calls/webhooks: concurrency = 8-16

PM2 Clustering

Enable process clustering within a container:
.env
When AP_PM2_ENABLED=true, PM2 starts one process per CPU core using cluster mode with -i 0.See docker-entrypoint.sh:20 for implementation.

Database Scaling

Connection Pooling

Adjust pool size based on instance count:

PostgreSQL Max Connections

Increase PostgreSQL max connections:
Or for managed databases:
Parameter Groups → max_connectionsFormula: {DBInstanceClassMemory/9531392}

Read Replicas

Offload read queries to replicas:
.env
Activepieces doesn’t currently support read replica configuration. Consider using connection poolers like PgBouncer instead.

Redis Scaling

Redis Cluster

For high-throughput deployments, use Redis Cluster:
.env

Redis Sentinel

For high availability:
.env

Job Retention

Control queue memory usage:
.env

Load Balancing

Nginx

Kubernetes Ingress

Monitoring Scaling

Metrics to Monitor

Monitor Redis queue depth:
Scale workers when:
  • Waiting jobs > 100
  • Average wait time > 30s
Monitor worker CPU/memory:
Scale when:
  • CPU > 80%
  • Memory > 80%
Monitor API latency:
Scale APP containers when:
  • p95 latency > 500ms
  • Error rate > 1%
Monitor PostgreSQL connections:
Adjust when:
  • Active > 80% of max
  • Connection errors in logs

Queue UI

Enable BullMQ Board for visual monitoring:
.env
Access at: http://your-domain/admin/queues

Performance Optimization

Execution Mode

Use sandboxed execution for production:
.env

Timeouts

Adjust based on your workflow needs:
.env

Caching

Enable piece caching:
.env

Scaling Checklist

1

Database

  • Increase max_connections in PostgreSQL
  • Adjust AP_POSTGRES_POOL_SIZE per instance
  • Enable connection pooling (PgBouncer)
  • Setup database replication for HA
2

Redis

  • Configure Redis persistence
  • Setup Redis Sentinel/Cluster for HA
  • Monitor queue depth
  • Configure job retention
3

File Storage

  • Migrate to S3 from local storage
  • Enable S3 signed URLs
  • Configure lifecycle policies
4

Application

  • Separate APP and WORKER containers
  • Configure worker concurrency
  • Enable PM2 for APP containers
  • Setup load balancer
5

Monitoring

  • Setup metrics collection
  • Configure autoscaling
  • Enable queue UI
  • Setup alerting

Next Steps

Workers

Deep dive into worker architecture

Architecture

Understand system components

Database

Optimize database performance

Monitoring

Setup monitoring and alerts