Executing several servers (webapi) with the same job at the same time

Hello all,

we want to deploy several webapi servers running hangfire in the background with the same configuration for all of them.

Our target is run the same recurring job every 15 minutes but only by one server at the same time. But it is not important what server runs the job.

I mean, we have (ie) 2 servers running the same recurring job every 15 minutes. The first running the job, wons. The other must not runs the same job again if no 15 minutes has left out from the previous execution. This means also the first server will fun the job when it is time to do it (15 minutes after).

If the first server fails or shutdown, the second will check when its time arrives and execute the job safely.

It is as a horizontal fault tolerance configuration for all servers. Only one job.

It is possible with HangFire (I suspect it is not).
Regards.

Actually take a look at link below. If you are sharing same sql server, you may be able to achieve this.

Hi, thank you so much.
It seems running fine on our tests (with 2 servers) applying the attribute DisableConcurrentExecution.

Only one more question:
If I execute 2 servers (or more) on different computers, what is the server taking the control? Are there any way to know it?

Thanks again…