locked
Workflow performance- initial load RRS feed

  • Question

  • we have a wcf service with operations to createworkflow, startworkflow and resume a workflow. this uses a workflowapplication object per request for create/start/execute workflow. we are using WF4 foundation. The issue we are having is our initial cold start of workflow service is very slow. for example, during profiling i noticed that waiting on the application.begin/endrun method return instantly but blocked at awaiting taskcompletionsource return value for as much as 15 seconds.  this does not happen during warm run and its faster compared to initial load.

    Can anybody provide some inputs such as what is going on for the first request to the per call wcf service which creates executes a workflow using workflow applications begin/endrun method and wait for taskcompletionsource. i beleive .NET wF4 runtime is taking long time initializing something while its doing this. but it is a total blackbox.

    The other issue is we have xaml based workflows so we load them at runtime from database, compile it the first time and put the dynamicactivity(from compilation) into an in memory cache. even the compilation using activityxamlservices.load takes significant time as much as 3 seconds or more depending upon complexity of sequential workflow. any ideas how we can improve this further? we have a combination of c# and Vb workflows

    we have considered pre-compiling xamls but out workflow authoring experience goes for a toss and it introduces binary dependencies on the compiled xaml. we have also considered setting compileexpressions to false parameter to activityxamlseervices.load but that does not work with c# workflow. it only works with vb workflows.

    any ideas will be appreciated.

    Thursday, October 16, 2014 6:32 AM

Answers

  • VPole,

    Thank you for your questions.

    I want to make sure I understand the long processing times you are encountering.

    The first seems to be when you use ActivityXamlServices.Load to create a
    DynamicActivity from XAML, with the CompileExpressions setting set to "true".
    As you point out, the processing time to do this will vary based on the size
    of the workflow defintion, and also on the number of expressions you have
    used in the workflow definition.

    Have you tried writing a small console application that simply does the
    ActivityXamlServices.Load call on the XAML definition and then try to profile
    where the time is being spent? That data should be useful in determining
    what is taking so long and it would isloate the profiling data to just
    the loading of the XAML and compiling of the expressions.

    I am a little unclear on where the second long processing time is happening.
    It sounds like it occurs the first time you use the DynamicActivity to
    create an instance of a WorkflowApplication and call [Begin]Run on it. But the
    next time you do those same operations in the same process, you don't see
    the long processing time. Is that correct? Is the unexpected "delay"
    when you call [Begin]Run and when it returns/invokes the AsyncCallback?
    Or is in the time it takes the workflow instance to reach its first idle
    point or to complete?

    Does this "Run delay" only occur on the very first WorkflowApplication instance
    for the process? Or does it happen for the first WorkflowApplication instance
    for a given DynamicAcitivty instance? In other words, does it only happen
    once per process, or does it happen once per workflow definition? This question
    assumes that you are hosting multiple workflow defintions in the same process.

    Are you using an InstanceStore to persist idle workflow instances?
    If yes, are you using SqlWorkflowInstanceStore?
    If yes, is the SQL Server instance located on the same machine or
    on a different machine?
    Are you creating a different instance of SqlWorkflowInstanceStore for
    each WorkflowApplication instance? Or are you using a single instance
    of SqlWorkflowInstanceStore for all WorkflowApplication instances?

    Thanks.

    Jim

    • Marked as answer by Angie Xu Monday, October 27, 2014 2:08 AM
    Thursday, October 16, 2014 5:00 PM