Search code examples
c#multiprocessingwindows-servicestask

multi tasking vs multi process in a machine


I'm a little confused. I have some jobs.I can do it with many windows 3 services like service1 ,service2,service3 at same machine or i can do it this jobs with starting Task 3 times with Task.Factory.StartNew(() => {//mytask});

I know, with task i have single process at the machine but with many services i have multible process but what is the difference when using system resource. Which way is the true way.

(all these services and/or start task will listen some queue as consumer) (and 3 just an example for compare) (a single job may take 3 minutes)


Solution

  • (Oversimplified and not full answer)

    Process is expensive:

    • Process creation is much more expensive
    • Processes synchronization is much more expensive and difficult to implement

    But

    • When one process crashes it doesn't affect other process that can continue handling their job. But crash in one task may crash the whole process stopping other tasks from processing their work
    • Processes can run on different machines allowing to scale over more resources while tasks will always run on same machine competing for resources.