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
@@ -0,0 +1,36 @@
"""Add worker_configs table for dynamic concurrency settings.
Revision ID: 054
Revises: 053
"""
from alembic import op
import sqlalchemy as sa
revision = "054"
down_revision = "053"
branch_labels = None
depends_on = None
def upgrade() -> None:
op.create_table(
"worker_configs",
sa.Column("queue_name", sa.String(100), primary_key=True),
sa.Column("max_concurrency", sa.Integer, nullable=False, server_default="8"),
sa.Column("min_concurrency", sa.Integer, nullable=False, server_default="2"),
sa.Column("enabled", sa.Boolean, nullable=False, server_default="true"),
sa.Column("updated_at", sa.DateTime, nullable=False, server_default=sa.text("now()")),
)
# Seed default rows
op.execute("""
INSERT INTO worker_configs (queue_name, max_concurrency, min_concurrency, enabled)
VALUES
('step_processing', 8, 2, true),
('thumbnail_rendering', 1, 1, true),
('ai_validation', 4, 1, true)
ON CONFLICT DO NOTHING
""")
def downgrade() -> None:
op.drop_table("worker_configs")