Base solution for your next web application
Open Closed

Tenant Background Workers #1939


User avatar
0
saasygreene created

We are using a singleton periodic background worker to collect data from web services for all the tenants. I was wondering if anyone has tried making a tenant background workers using transient dependency. This would allow each tenant's background worker to complete it's requests in it's own time, with it's own timer, start and stop methods. I have been caching my web service results. I'm considering this because I don't want one tenant to delay another tenant. Any recommendations?


2 Answer(s)
  • User Avatar
    0
    saasygreene created

    Am I understanding transient correctly? That it means everywhere it is injected is a new instance. Maybe I am looking for something like a ITenantSingletonDependency...

  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    Background jobs/workers are not per tenant. I suggest you to create a new thread for each tenant inside your worker then execute them in parallel (you should handle multi-tenancy yourself). But notice that this can be a problem if say that you have too many tenants. So, you may want to use a thread pool instead. Such batch tasks should be carefully designed and optimized. But these topics are out of scope of AspNet Zero, they are generic software development stuff.