feat(phase8.1-8.2): dynamic worker concurrency via worker_configs

- Migration 054: worker_configs table (queue_name PK, max/min_concurrency,
  enabled, updated_at); seeds step_processing(8/2), thumbnail_rendering(1/1),
  ai_validation(4/1)
- WorkerConfig SQLAlchemy model
- apply_worker_concurrency beat task: reads enabled configs, broadcasts
  pool_grow to all Celery workers every 5min
- GET/PUT /api/worker/configs (admin): list + update per-queue concurrency
- docker-compose.yml: worker uses --autoscale=${MAX_CONCURRENCY:-8},${MIN_CONCURRENCY:-2};
  render-worker uses --autoscale=1,1 --concurrency=1
- WorkerManagement.tsx: "Concurrency Settings" section with +/- steppers
  and Save button per queue

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-08 20:41:57 +01:00
parent b41e70cdad
commit 07e3d1e026
9 changed files with 344 additions and 5 deletions
+31
View File
@@ -166,3 +166,34 @@ export async function scaleWorkers(req: ScaleRequest): Promise<ScaleResponse> {
const res = await api.post<ScaleResponse>('/worker/scale', req)
return res.data
}
// ---------------------------------------------------------------------------
// Worker concurrency configuration
// ---------------------------------------------------------------------------
export interface WorkerConfig {
queue_name: string
max_concurrency: number
min_concurrency: number
enabled: boolean
updated_at: string
}
export interface WorkerConfigUpdate {
max_concurrency?: number
min_concurrency?: number
enabled?: boolean
}
export async function getWorkerConfigs(): Promise<WorkerConfig[]> {
const res = await api.get<WorkerConfig[]>('/worker/configs')
return res.data
}
export async function updateWorkerConfig(
queueName: string,
update: WorkerConfigUpdate,
): Promise<WorkerConfig> {
const res = await api.put<WorkerConfig>(`/worker/configs/${queueName}`, update)
return res.data
}