Lisa Holenstein
ServiceNow Employee
ServiceNow Employee

Workflow Automation CoE > FlowsBest Practices > Performance

 

Flows Best Practices Performance

 

  • Disable Flow reporting for optimal performance.
  • QuickAPI is available to run a flow, subflow, action, or Data Stream action from a server-side script synchronously or asynchronously without creating a flow context execution details or other related records.
    • Improves performance by eliminating record-keeping overhead.
    • Use this API to increase the speed of high-volume processing, for example multiple executions per second, in a production environment.
    • No record will exist for the execution attempt or details. Any record keeping will be the duty of the calling method, or as an operation of the flow (for example, using the Log action to write a message to the system log).
    • The Quick Flow cannot pause or wait, as there is no context to wake-up.
  • Run in parallel.
  • Avoid parallel branches which depend on each other.
  • Execute flows in background to release UI threads.
  • Never use gs.sleep()
    • Flow uses the system scheduler to pause, then resume on schedule. This releases the thread processing the flow for other work on the platform to continue. gs.sleep() will tie up and hold the current thread, preventing new work from being done.
  • Minimize switching between the Instance and the MID.
  • Avoid interleaving instance (Glide) only and MID only steps.

Looping

  • Consider setting com.snc.process_flow.reporting.iteration.lastn to 1 (default 50).
    • When reporting is on, previous loop iterations are stored in memory. In large loop scenarios this can use an unnecessary memory footprint for the flow execution.
  • Don't iterate over 1000 items or iterations in For-Each or Do-While Flow Logic.
  • If you need to loop over more than 1000 records, create a flow that processes smaller chunks then ends, releasing all resources after each execution.
  • Don't batch load more than 100 flows to trigger at once, instead chunk over your items. Create a flow that calls a subflow passing a list of less than 100 items at once, to process those items serially.
    • Optionally, you may use Parallel Flow Logic to process across more than one thread.
    • Caution, do not create parallel to launch flows asynchronously, as you'll quickly flood the event queue. Ensure each parallel branch processes an entire batch, before iterating and starting the next set.
  • Avoid loops without a valid exit condition.
    • If a natural exit condition does not exist, add a Flow Variable that your Do-While loop uses as the exit condition, and set the Flow Variable each iteration to ensure your desired iterations occur and exit the loop gracefully.
  • Note: Inline script loops are not caught by flow property.
  • For data import, consider using concurrent imports for mass data load.

 

Center of Excellence Navigation

  1. Workflow Automation - Center of Excellence
  2. Workflow Automation Migration Considerations
  3. What's new for Workflow Automation?
  4. Resource Hubs
    1. Flows
    2. Decision Tables
    3. Playbooks
  5. FAQ
  6. Training
  7. Workflow Academy
Version history
Last update:
‎04-17-2024 01:44 AM
Updated by:
Contributors