BlazorWorker
BlazorWorker copied to clipboard
Understanding Worker and BackgroundService instances
I have a few questions regarding the use of IWorker
instances and IWorkerBackgroundService
instances.
- Having created a background service for on a
Worker
instance, is there any point in keeping the worker instance around? Can I for example spawn multiple BackgroundServices from the same Worker instance? If so, I suppose they can only run once at a time, since they are on the same Worker? - Is diposing of the
IWorker
instance sufficient or do I separately need to dispose of theIWorkerBackgroundService
s? (BTW is there an actual need for disposing workers in practise?) - If Workers and BackgroundServices are always a 1-1 relationship, why not allow creating a Background service through a factory method which also implicitly creates a Worker? Just a thought with a lot of "ifs"...
Had high hopes to improve performance in our application using workers but I am starting to see some of the limitations really becoming problems. For example, the cost of serialization + deserialization to pass data may at times overweigh the benefit of doing calculations in parallel, probably depending on the complexitiy of the task. I got some PoC code working with our app but managed to decrease performance by quite a lot... I guess due to massive amounts of serialization work as well as unability to utilize our cache well enough (as it would be global and workers cannot access global things)