Skip to main content

Workers API

List Workers

GET /api/v1/workers
Response:
{
  "workers": [
    {
      "id": "worker_abc123",
      "hostname": "web-1",
      "pid": 12345,
      "status": "active",
      "queues": ["default", "mailers"],
      "concurrency": 5,
      "busy_threads": 3,
      "started_at": "2024-01-15T08:00:00Z",
      "last_heartbeat": "2024-01-15T10:30:00Z",
      "processed_count": 4521,
      "failed_count": 12,
      "memory_mb": 256,
      "cpu_percent": 15.2
    }
  ],
  "summary": {
    "total_workers": 5,
    "total_threads": 25,
    "busy_threads": 18,
    "idle_threads": 7
  }
}

Get Worker Details

GET /api/v1/workers/:id
Response:
{
  "id": "worker_abc123",
  "hostname": "web-1",
  "pid": 12345,
  "status": "active",
  "queues": ["default", "mailers"],
  "concurrency": 5,
  "busy_threads": 3,
  "started_at": "2024-01-15T08:00:00Z",
  "last_heartbeat": "2024-01-15T10:30:00Z",
  "processed_count": 4521,
  "failed_count": 12,
  "memory_mb": 256,
  "cpu_percent": 15.2,
  "current_jobs": [
    {
      "job_id": "job_xyz",
      "class_name": "ProcessOrderJob",
      "started_at": "2024-01-15T10:29:58Z",
      "run_time_seconds": 2
    }
  ]
}

Get Worker Stats

GET /api/v1/workers/stats
Query Parameters:
  • period - Time period: hour, day, week
Response:
{
  "period": "day",
  "stats": {
    "avg_workers": 4.8,
    "max_workers": 5,
    "min_workers": 4,
    "avg_utilization": 72.5,
    "total_processed": 45210,
    "total_failed": 120,
    "avg_memory_mb": 245,
    "max_memory_mb": 312
  },
  "timeline": [
    {
      "timestamp": "2024-01-15T10:00:00Z",
      "workers": 5,
      "utilization": 75.2,
      "throughput": 92
    }
  ]
}

Quiet Worker

Signal worker to stop accepting new jobs.
POST /api/v1/workers/:id/quiet
Response:
{
  "id": "worker_abc123",
  "status": "quiet",
  "message": "Worker will finish current jobs and stop accepting new ones"
}

Stop Worker

Signal worker to stop after completing current jobs.
POST /api/v1/workers/:id/stop
Response:
{
  "id": "worker_abc123",
  "status": "stopping",
  "message": "Worker will stop after completing current jobs"
}

Quiet All Workers

POST /api/v1/workers/quiet-all
Response:
{
  "workers_quieted": 5,
  "message": "All workers will stop accepting new jobs"
}