Repository navigation
Horizontal Worker scaling with PostgreSQL claim coordination #69
bitbiter-dev
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Problem
A single Worker is a processing bottleneck when a deployment has many users or very large libraries. There is no way to add capacity without architectural changes.
Proposed mechanism
Add two columns to
MediaAsset:claimed_by_worker_id(guid, nullable)claimed_at(datetime, nullable)Before processing a file, a Worker atomically claims it:
If the claim succeeds the Worker processes the file; if not, another Worker already has it. Stale claims (Worker crashed mid-job) expire after a configurable timeout and become available again.
Workers without
WORKER__USERall draw from the global pool safely — the claim prevents duplicates. Fair round-robin scheduling still applies per-Worker across users.No external coordinator needed — PostgreSQL row-level locking or advisory locks are sufficient. No Redis, no Hangfire.
Questions to resolve before implementing
WORKER__ID) or auto-generated (UUID on startup)?Not in scope for v1.0
Revisit after Epic 4 (reconciliation) is stable and single-Worker performance has been measured in practice.
All reactions