Base solution for your next web application
Open Closed

Background Job - Multiple Instances #11291


User avatar
0
mahendra created

Prerequisites

Please answer the following questions before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.

  • What is your product version?
  • What is your product type (Angular or MVC)?
  • What is product framework type (.net framework or .net core)?

If issue related with ABP Framework

  • What is ABP Framework version?

If issue is about UI

  • Which theme are you using?
  • What are the theme settings?

Hi,

Refering to the below document https://aspnetboilerplate.com/Pages/Documents/Background-Jobs-And-Workers#disabling-job-execution specifically the point "You can enable job execution for only one instance of the application.", could you please elaborate how can we do this....

I am using Azure AppService and am scaling it out to say 5 instance. now how can I ensure that only one instance should run the background job and not any other instances else the same background job is picked-up by multiple instances and that cause data duplication in the database.

Regards, Mahendra


3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi Mahendra,

    You can store a config in appsettings.json file and enable background jobs by looking at the value of this setting. For each instance, you can set the value of this config in environment variables. If you set it to false by default, you only need to set it to true for 1 instance which you want to enable background jobs.

  • User Avatar
    0
    mahendra created

    Hi ismcagdas,

    Sorry, am slightly confused..... In azure you have two scaling mode: Manual and Auto. So if I have setup Auto scaling mode and then on what basis I enable the background job....

    Could you please give me an example...

    Regards, Mahendra

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @mahendra

    In that case, you can use 1 instance with manual scaling mode which executes the background jobs and 1 automatic scaling mode which doesn't executes the background jobs.