SyncETA Capacity Scaling (Part 2) — KEDA ScaledObject & Graceful Scale-In for Active Tests
- ChallengeScaling down immediately when the waiting queue hits zero risks killing pods that are still running browser scenarios mid-flight.
- ApproachSyncETA monitors both BullMQ wait and active keys (bull:scheduler_jobs:wait / active) via KEDA ScaledObject, paired with 180s termination grace periods, SIGTERM draining, and stabilization windows.
- ImpactWorkers scale out rapidly during release bursts while scaling down gradually only after active scenarios finish and upload evidence cleanly.
Technical Deep Dive for IT & Engineering Teams
In Part 1, we explained why CPU/memory HPA misfires for isolated browser workers and why Redis queue depth is the right demand signal. In Part 2, we walk through how SyncETA's BullMQ queue (scheduler_jobs) and dedicated worker deployment (APP_ROLE=worker) integrate with KEDA ScaledObject and graceful scale-in controls.
1. SyncETA Worker Runtime & BullMQ Redis Keys
SyncETA runs its API server and workers from the same container image, switching modes via APP_ROLE=worker. In worker mode (worker-main.ts), NestJS boots a headless application context without HTTP overhead so SchedulerJobProcessor consumes jobs from the BullMQ scheduler_jobs queue.
- Waiting queue (
bull:scheduler_jobs:wait): Queued scenarios not yet picked up by a worker. - Active queue (
bull:scheduler_jobs:active): Scenarios currently executing inside a worker pod's browser and Playwright MCP session.
Monitoring only wait causes premature scale-in as soon as all queued jobs move to active. Watching both wait and active keeps desired replicas aligned with total live workload.
2. KEDA ScaledObject & Secret-Backed TriggerAuthentication
Redis credentials remain inside Kubernetes Secret objects referenced through KEDA TriggerAuthentication:
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: sync-eta-redis-auth
namespace: sync-eta
spec:
secretTargetRef:
- parameter: password
name: worker-secret
key: REDIS_PASSWORD
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: sync-eta-worker-scaler
namespace: sync-eta
spec:
scaleTargetRef:
name: worker
pollingInterval: 15
cooldownPeriod: 300
minReplicaCount: 2
maxReplicaCount: 12
advanced:
horizontalPodAutoscalerConfig:
behavior:
scaleUp:
stabilizationWindowSeconds: 0
policies:
- type: Pods
value: 4
periodSeconds: 30
scaleDown:
stabilizationWindowSeconds: 300
policies:
- type: Pods
value: 1
periodSeconds: 60
triggers:
- type: redis
metadata:
address: redis.sync-eta.svc.cluster.local:6379
listName: bull:scheduler_jobs:wait
listLength: "1"
authenticationRef:
name: sync-eta-redis-auth
- type: redis
metadata:
address: redis.sync-eta.svc.cluster.local:6379
listName: bull:scheduler_jobs:active
listLength: "1"
authenticationRef:
name: sync-eta-redis-auth
3. Four Safeguards Protecting Active Browser Runs
terminationGracePeriodSeconds: 180: Configured directly on the worker Deployment so in-flight scenarios and.webmvideo uploads finish before forced termination.shareProcessNamespace: true: Allows PID 1 inside the pod to reap zombie Chromium child processes cleanly.- Graceful BullMQ Shutdown on
SIGTERM: Callingapp.close()pauses new job pulls immediately while awaiting completion of the active job. - Node Headroom & Control-Plane Exclusion:
nodeAffinitykeeps workers off control-plane nodes, while calibrated CPU/memory limits (2.3CPU /4GiRAM) preserve kubelet headroom.
4. Production Verification Checklist
- Trigger 20 simultaneous scheduled scenarios and observe
kubectl get hpa -n sync-eta -wscaling smoothly up to the configured cap. - Confirm zero aborted test histories and complete
.webmevidence uploads during scale-down windows. - Track OOM events and residual Chromium process counts in Prometheus/Grafana.