What is the difference between DisableConcurrentExecution and Worker Count = 1?
I set Worker Count = 1 in my BackgroundJobServerOptions but it seems that both jobs executed (only one queue). What is the point of setting this value if more than one job can run?
They do essentially the same thing IF you are only using a single backgroundjob server.
DisableConcurrentExecution
This is a per job attribute that ensures that two instances of the class/method name are not running at the same time. This is accomplished by a distributed sql lock if using SQL server backend. A worker will pick the job up and attempt to acquire the lock for the job/method name with the given timeout. Note that the worker process will be "busy" while it is waiting for the SQL lock to open up and will be unable to process other jobs.
Worker Count = 1
This is a per hangfire backgroundjob server instance setting. If you have a single hangfire backgroundjob processing server, setting this to one essentially causes all your jobs to not run concurrently (only one job processor). If you have two servers running with both having a WorkerCount of 1, your jobs will run concurrently because your total worker pool is 2. The DisableConcurrentExecution attribute will ensure the job does not run concurrently regardless of the number of workers or servers you have activated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With