7.4.3 Workflow Design
Workflow design affects duration and use of resources. The following are design guidelines for workflow design:

Effective scripting
– Use s
cripting development design guidelines
to avoid unnecessary and highly resource-demanding operations such as active wait loops, repetitive expensive calls to the same reso
urces, and ineffective algorithms. Perform e
xtensive testing on a vCenter Orchestrator test server before
running new or updated workflows on a production system.
Workflow threading control
– Having many
distinct running workflows increases the amount of
resources are used.
Workflows started individually and workflo
ws started using the Asynchronous Workflow or Nested Workflow palette elements run in different workflow instances.
A sub-workflow in a master workflow still runs
within the same workflow instance, but
uses fewer resources. Link
the workflows in higher-level workflows instead of calling individual workflows in sequence.

Reduce
the number of waiting workflows
– If the reason
for the high concurrency is due to a high number of workflows waiting on external systems, the following methods can help
avoid consuming resources while waiting:
The
Wait Until date workflow palette element and the System.Sleep() methods keep the workflow in a running state in the execution queue. Even if the thread is in Sleep mode,
it still consumes memory. For long running workflows,
these can be replaced by the waiting timer or waiting event palette elements. Using one of these elements passivates the workflow execution and saves
its state in the vCenter Orchestrator database. The workflow is then removed from the running queue and memory is freed. The vCloud Director library’s
long running workflows make extensive use of the waiting event palette element.
When workflow activity must
be suspended until a determined time,
programmatically schedule
a workflow task.Although they save active resources, each passivation and activation consumes CPU resources and database access. The following are design guidelines for using the waiting timer or waiting event:

Do not trigger a large number of these at the same time.

Do not set very short timers in loops.