Queue priority and workers per queue?

Can anyone explain in better detail how queues work? The documentation is pretty light on the inner-workings of it.

If I have one server with three queues and 20 workers, how are those 20 workers divided up if there were a hundred jobs ready to run in each of the three queues?

I’ve seen some people mention queue priority being alphabetical or something of that sort but it isn’t clear how that works.

If I have queues of “thirdParty”, “framework”, and “background”, are they automatically assigned priority given where they are in my array of queues? If a job tries to fire in each queue, does the first listed queue always win the race?

One other question:
If I want my workers to be evenly split/available to each queue, how can I do that instead of a first-come-first-serve pool?

We generally don’t use multiple queues per BackgroundJobServer so I don’t have answer as to how work is pulled off queues.

For your second question, you can have multiple BackgroundJobServers running per process, each with an individual queue & worker count. So you could set up one BackgroundJobServer per queue with 7 workers. Hard to recommend a configuration without knowing what problem you’re trying to solve by utilizing multiple queues.

Sorry for highjacking… but I have a specific businesscase where I need different workercount per queue.

I want one queue where I have just 1 worker, ensuring all jobs going here is executed serially… and then one queue where all can be executed as the number of workers allows…

The reason for this is a number of jobs I need to make sure they get executed in the order they get enqueued as they depend on each other.

My config:

        services.AddHangfire(x => x.UseSqlServerStorage(Configuration.GetConnectionString("DbConnection")));

        services.AddHangfireServer(x => new BackgroundJobServerOptions
        {
            //ServerName = "TMServer-Serial",
            Queues = new[] {"serial"},
            WorkerCount = 1
        });

        services.AddHangfireServer(x => new BackgroundJobServerOptions
        {
            //ServerName = "TMServer-Default",
            Queues = new[] { "default" },
            WorkerCount = Environment.ProcessorCount * 3
        });

But this only results in 2 servers both with default queue… no trace of the serial queue anywhere… except I see my jobs being enqueued to it, but never executed… probably because no server has that queue.

I am on dot net 5.