AddOrUpdate/etc commands - safe to run on all web server startup (when using multiple servers w/HF)


#1

We are using multiple web servers, pointed at the same Hangfire Redis database, and it works, but on our application startup we are calling AddOrUpdate for 20+ jobs - and I wondered if this was a best practice. That same application startup code is running on each of our web servers. Seems like there could be a race or weird condition there? What is the best way to just fire off AddOrUpdate once? I suppose I could use a “global lock” pattern or something like that - but wondered if this is an issue others have encountered.

Another part of this equation - we are wanting to wipe recurring jobs at startup and always “start fresh” with latest defined ones - so I imagine having the code to erase all recurring jobs and then re-add them – if it runs on different web servers at startup – will cause problems.

Thanks for any guidance.