views:

62

answers:

3

Hello I've quite unordinary problem because I think that in my case workflow runtime doesn't use enough CPU power. Scenario is as follow:

  1. I send a lot of messages to queues. I use EnqueueItem method from WorkflowRuntime class.
  2. I create new instance of workflow with CreateWorkflow method of WorkflowRuntime class.
  3. I wait until new workflow will be moved to the first state. Under normal conditions it takes dozens of second (the workflow is complicated). When at the same time messages are being sent to queues (as described in the point 1) it takes 1 minute or more.

I observe low CPU (8 cores) utilization, no more than 15%. I can add that I have separate process that is responsible for workflow logic and I communicate with it with WCF.

A: 
Goz
1. When the activity receives the message it calls CloseActivity method.2. I have a tool that monitor number of available threads. On my computer there is 2000 threads in pool and during processing no more than 20-25 of them is in used.3. I don't perform any operations on a file system except logging. However, I use Logging Application Block from Enterprise Library so I think it is not a problem.4. As I've said a workflow is complicated, it contains many database operations. I've prepare a test in which some of activities were disable. In this case the workflow was processed faster.
Michał Komorowski
As to a number of threads I use thread pool managed by.NET runtime. This pool decides, based on a machine configuration, how many threads should be created. For example on my colleague computer this pool contains "only" 500 threads. How Do you think? What is a best way to determine a good number of threads in pool assuming that default number of threads can be too high or too low?
Michał Komorowski
Well a lot depends on how the pool is managed. If it doesn't allocate many threads when the threads are hitting the CPU hard then its not an issue. Alas, I really don't know enough about its thread pooling system to be able to quantify an answer on that, I'm afraid :(
Goz
+1  A: 

You've got logging, which you think is not a problem, but you don't know. There are many database operations. Those need to block for I/O. Having more cores will only help if different threads can run unimpeded.

I hate to sound like a stuck record, always trotting out the same answer, but you are guessing at what the problem is, and you're asking other people to guess too. People are very willing to guess, but guesses don't work. You need to find out what's happening.

To find out what's happening, the method I use is, get it running under a debugger. (Simplify the problem by going down to one core.) Then pause the whole thing, look at each active thread, and find out what it's waiting for. If it's waiting for some CPU-bound function to complete for some reason, fine - make a note of it. If it's waiting for some logging to complete, make a note. If it's waiting for a DB query to complete, note it. If it's waiting at a mutex for some other thread, note it.

Do this for each thread, and do it several times. Then, you can really say you know what it's doing. When you know what it's waiting for and why, you'll have a pretty good idea how to improve it. That's a variation on this technique.

Mike Dunlavey
A: 

WF3 performance is a little on the slow side. If you are using .NET 4 you will get a better performance moving to WF4. Mind you is means a rewrite as WF4 is a completely different product.

As to WF3. There is white paper here that should give you plenty of information to improve things from the standard settings. Look for things like increasing the number of threads used by the DefaultWorkflowSchedulerService or switching to the ManualWorkflowSchedulerService and disabling performance counters which are enabled by default.

Maurice
I know that WF4 is faster than WF3 but currently I can't switch to newer technology because of lack of backward compatibility and lack of time to make migration. I’ve already found this white paper and you are right it is really good.
Michał Komorowski