In a Saas app, we want order imports to run in serial for each tenant. But multiple order imports can run concurrently for different tenants (up to a point). Then also runs other types of jobs that again I’d like to run serially by tenant, but multiple tenants can run concurrently.
i.e.
OrderImportServer – max 20 workers total
- Tenant1q_OI – runs serial
- Tenant2q_OI – runs serial
- Tenant3q_OI – runs serial
OrderReleaseServer – max 20 workers total
- Tenant1q_OR – runs serial
- Tenant2q_OR – runs serial
- Tenant3q_OR – runs serial
How can you accomplish this in Hangfire?
We’re using Asp.Net and Hangfire version 1.8.11 utilizing SQL Server for hangfire storage.
I was hoping I could set a WorkerCount
by server to indicate the max number of concurrent jobs running and then have queues inside the server that run serially (i.e. max of 1 worker per queue), but I’m unclear it the latter is possible. i.e. if I set a server to use 4 workers, and only 1 queue has 10 enqueued jobs, I’m afraid the queue will then run jobs 1 – 4 in parallel, which I don’t want.
Is there a way to accomplish this desired result? Perhaps using a Server per tenant that has 1 WorkerCount
and then limit the max concurrent jobs via the [MaximumConcurrentExecution][1]
?
OrderImportTenant1Server
- OIT1Q
OrderImportTenant2Server
- OIT2Q
OrderReleaseTenant1Server
- ORT1Q
OrderReleaseTenant2Server
- ORT2Q
This just seems like a lot of servers with 1 queue each…not sure that matters from a technical perspective, it just seems easier to think of a “Server” as a job type (Order Import vs Order Release) and then have queues by tenant within them.