Running Hangfire jobs on a specific server

I have the following setup:

  • Multiple web servers running in a load balanced setup. Each of these can enqueue jobs of course.
  • An admin server that also runs the website. Editors create and edit content on the admin server and it is then pushed to the web servers
  • Web servers and the admin server share the same Hangfire database (SQL)

My question is if I can somehow allow every server (web and admin) to enqueue jobs, but only allow the admin server to execute the jobs?

Hangfire Server component is being used to execute your background jobs. Default Hangfire setup includes the following lines:

// Using OWIN extensions (for web apps):
app.UseHangfire(config =>

// Or direct class instantiation (for non-web apps):
var server = new BackgroundJobServer();

If you omit the UseServer or Start method invocation, then your background jobs will not be processed. So, you can disable processing for your web apps, but include the calls in admin server.

Thanks for the reply. Can the web apps still enqueue jobs even though they can’t process them?

I don’t have server.Start() and yet my server processes jobs, I do use it to add new jobs onto queues although that’s pretty much all I want to do. I have another server which I have dedicated to processing the jobs. Can you point me in the right direction to figure out why that unwanted server is processing my jobs?