You are viewing limited content. For full access, please sign in.

Question

Question

Is workflow a single threaded or multi threaded application

asked on September 26, 2014 Show version history

If we have a workflow say WF1 is running and processing some documents and in the mean time another workflow say WF2 gets triggered as well, so what would happen?

Would WF2 go in a queue and wait for WF1 to finish, or they both can run simultaneously?

 

Scenario:

The purpose for asking this is, we have a situation where we will have some workflows (lets say one of them is WF1) running and processing documents. In the mean time, we would get an urgent request of processing some documents on priority basis. We will import the priority documents in a priority folder in Laserfiche, which triggers WF2. So as WF1 and other worklfows are still in progress, would WF2 go into wait/queue or WF2 would trigger immediately and start processing documents simultaneously.

1 0

Answers

APPROVED ANSWER
replied on September 26, 2014

For your exaction question Uzair, WF2 will run. 

I wanted to provide the official description of how this works. I will be covering this topic in AED224: Optimizing Workflow Performance at the empower 2015 conference. This description covers workflow 8.0 through 9.2.

Workflow is a multi-threaded application with the following rules:

  • Each version of a published workflow runs in a container called a workflow runtime.
  • Each workflow runtime has a pool of threads (4x # of logical cores) for all instances of that workflow version to run on.
  • A given instance of a workflow is single threaded on one of these runtime threads

 

In my presentation, I like to describe this using the concept of a carnival 'fun' slide:

 

WF1 and WF 2 each have their own slide (these are 2 core slides, so 8 threads each) . When an instance wants to run an activity, it queues up the staircase and goes down the slide (like a fun slide, you can't go down the slide until its cleared out). So as long as WF 2 is not running more then 4x # logical core instances already, it'll start running immediately.

Last thing to address, parallel activities in a workflow, how are they parallel if workflow instances are single threaded! The answer usually depends on what the parallel activity is doing, which in most cases, is waiting. When a workflow activity waits... Wait for Entry Change, Delay, or any of the 'external' activities that call out to the world like query data, scripts, etc. the workflow instance queues in the next activity to run on that thread, usually from a different parallel branch. This generally results in an interleaving pattern from the branches. Each instance being single-threaded provides a lot of performance benefits because it greatly reduces lock contentions for Laserfiche entries and database resources. 

Finally, for truely parallel execution, you should use invoke workflow. 

 

 

6 0
replied on September 26, 2014

Thanks Ed.

That clears a lot of confusion.

0 0
SELECTED ANSWER
replied on September 26, 2014

Uzair,

 

If I'm remembering things correctly from a past conference session on workflow, each activity in workflow is a separate thread. So if you have a workflow that has 15 steps in it, each step is a separate process that kicks off its own thread (in order if they are all linear, or in parallel at times if you use the parallel functions in workflow).

 

The link you posted is adjust the limits for the number of connections to outside resources. To limit or increase actual thread counts on the cpu's you'd use the Task Threads tab as outlined here.

 

So yes, both workflows should run at the same time unless they both happened to try to use the same resource and that resource has had it's limit reached. (such as email - it will only make one connection at a time to an email server by default)

 

 

2 0
replied on September 26, 2014

Thanks Chris. 

That clears the confusion.

0 0

Replies

replied on September 26, 2014

Is this where I will need to do some change to handle multi threading for mulitple starting rules to trigger simultaniously?

http://www.laserfiche.com/support/webhelp/WorkFlow/9.1/en-US/LFWorkflow.htm#Resources/Admin Console/Advanced Server Options Monitored Repositories.htm?Highlight=thread

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.