News for hackers. Stuff that matters.
Re:Building a fair multi-tenant queuing system by karldcampbell on Monday January 22, 2024 @02:48PM (#39094425)
As long as you don't need a strict priority and a worker can just grab the next waiting job:

  SELECT * FROM jobs ORDER BY RANDOM() LIMIT 1 SKIP LOCKED
should do the trick
Re:Building a fair multi-tenant queuing system by gnud on Monday January 22, 2024 @03:18PM (#39094842)
This will give more resources to tenants that schedule more jobs.

If tenant A schedules 99 jobs and tenant B schedules 1 job, a "fair" algorithm would pick B's job either first or second, RANDOM() will not.