Workflow Queue Setup - Dedicated Workers¶
Overview¶
Workflow tasks (trigger_agentic_workflow) are now routed to a dedicated workflows queue with dedicated workers, preventing them from being blocked by long-running source check tasks.
Changes Made¶
1. Celery Configuration (src/worker/celeryconfig.py)¶
Added workflow queue routing:
task_routes = {
# ... existing routes
'src.worker.celery_app.trigger_agentic_workflow': {'queue': 'workflows'},
}
task_queues = {
# ... existing queues
'workflows': {
'exchange': 'workflows',
'routing_key': 'workflows',
},
}
2. Docker Compose (docker-compose.yml)¶
Updated main worker to exclude workflows queue (note: collection_immediate is listed first so user-initiated "Collect Now" tasks are consumed before scheduled collection):
worker:
command: celery -A src.worker.celery_app worker --loglevel=${CELERY_LOG_LEVEL:-info} -Q collection_immediate,default,source_checks,maintenance,reports,connectivity,collection --concurrency=${WORKER_CONCURRENCY:-2} --without-gossip --without-mingle --without-heartbeat
Added dedicated workflow worker:
workflow_worker:
container_name: cti_workflow_worker
command: celery -A src.worker.celery_app worker --loglevel=${CELERY_LOG_LEVEL:-info} -Q workflows --concurrency=${WORKFLOW_WORKER_CONCURRENCY:-2} --without-gossip --without-mingle --without-heartbeat
# ... same environment and volumes as main worker
Benefits¶
- Isolation: Workflow tasks are never blocked by source checks.
- Performance: Dedicated workers run workflow execution without contention from other queues.
- Scalability: Workflow workers scale independently of the main worker (see Scaling).
- Reliability: Workflow failures don't affect other task types.
Restart Recovery¶
If a worker restart interrupts a workflow, its execution may remain marked running. On the next
trigger attempt for that article, an execution with no updated_at change for 30 minutes is marked
failed with a recovery message, which permits a forced retry. Recent executions are left running;
this recovers the trigger path only and does not resume interrupted work.
Deployment¶
Restart Services¶
Verify Setup¶
Check workflow worker is running:
Check queue routing:
docker exec cti_workflow_worker celery -A src.worker.celery_app inspect registered | grep trigger_agentic_workflow
Check worker is consuming workflows queue:
Monitor workflow tasks:
Queue Architecture¶
┌─────────────────┐
│ Main Worker │ → Processes: collection_immediate, default, source_checks,
│ (cti_worker) │ maintenance, reports, connectivity, collection
└─────────────────┘
┌─────────────────┐
│ Workflow Worker │ → Processes: workflows (trigger_agentic_workflow)
│(workflow_worker)│
└─────────────────┘
Monitoring¶
Check Queue Depth¶
Check Overall Worker Health¶
For a broader view (not just the workflows queue), see Agent Orientation -- Workers and schedules and the AGENTS.md "Runtime" section (repository root) for the restart requirement on cti_worker / cti_workflow_worker after .py changes.
Check Workflow Worker Stats¶
Check Active Tasks¶
Check Reserved Tasks¶
Troubleshooting¶
Workflow tasks still pending¶
-
Check workflow worker is running:
-
Check worker is consuming workflows queue:
Should showworkflowsqueue. -
Check for errors:
-
Verify task routing:
Worker not starting¶
-
Check Redis connectivity:
-
Check database connectivity:
Scaling¶
To scale workflow workers (e.g., for high evaluation load):
Or update docker-compose.yml:
Related Files¶
src/worker/celeryconfig.py- Queue and routing configurationdocker-compose.yml- Worker service definitionssrc/worker/celery_app.py-trigger_agentic_workflowtask
Last updated: 2026-07-03 Last reviewed: 2026-09-01