开发者

Should ALL activities within a WF Sequence contained in a ParallelFor be AsyncCodeActivity?

开发者 https://www.devze.com 2023-02-13 07:41 出处:网络
AI have a WF 4 application which contains a sequence workflow that has a ParallelFor containing a Sequence with three sequential activites.

AI have a WF 4 application which contains a sequence workflow that has a ParallelFor containing a Sequence with three sequential activites. The first of these activities is compute-bound (it generate Certificate Signing Requests), the second is IO bound (it sends emails) and the third task is also IO bound (it updates database).

I initially developed these all as CodeActivities and the saw that they need to be AsyncCodeActivities to truly run in multi-threaded mode. So I have modified the first compute-bound activity as an AsyncCodeActivity and I can see it is being executed multi-threaded. (At least I can observe much higher processor utilisation on my Dev machine which leads me t believe it is now running multi-threaded)

However the subsequent tasks remain as non-Async CodeActivities. My questions are as follows:

  1. Should I convert the 2nd and 3rd activities to Async as well (I suspect this will be the case)?

  2. 开发者_StackOverflow

    If not, how is the processing actually executed within the ParallelFor when the first is AsyncCodeActivitiy and the 2nd and 3rd are not?


With all child activities in a parallel they are scheduled at the same time. This means put in a queue and the scheduler will only execute a single at the time. With async activities this means that the start is scheduled and it can spawn other threads and the end part is scheduled when it is signaled as done and really executes when the scheduler get around to it.

In practice this means that for workflows that execute on a server with plenty of other work the async activity is best used for async IO like network or database IO. On a server adding multiple CPU threads to an already busy system can even slow things down. If the workflow executes on the client both async IO and CPU work make sense.

0

精彩评论

暂无评论...
验证码 换一张
取 消