Flow priority

  • Release version: Yokohama
  • Updated January 30, 2025
  • 3 minutes to read
  • Summarize
    Summarized using AI
    This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.

    Summary of Flow priority

    Flow priority in ServiceNow controls the execution order of background flows by assigning them priorities of High, Medium, or Low. Background flows run asynchronously using worker threads, which pick flows to run based on their priority. This feature helps manage workload efficiently by ensuring higher priority flows run before lower priority ones, improving system responsiveness for critical processes.

    Show full answer Show less

    Key Features

    • Priority Levels: Background flows can be set to High, Medium (default), or Low priority to influence their run order.
    • Worker Thread Management: Workflow Studio uses up to half of available worker threads to run background flows. If no thread is available, flows queue until a thread frees up.
    • Delegation: Flows waiting over a minute may be delegated to another node, where they lose priority and run in chronological order.
    • Pause Behavior: Flows lose their priority when paused and resume at Medium priority, regardless of original priority.
    • Automatic Pausing of Low-Priority Flows: Low-priority flows running longer than two minutes can be paused if there is a backlog of at least 100 high-priority flows, preventing blocking of critical work.
    • Quick API Support: Flows triggered by the quick API retain their assigned priority.

    Design Considerations

    • Avoid setting all flows to High priority; a mixture of priorities optimizes resource usage and avoids starvation of lower-priority flows.
    • Flows that require pausing should keep the default Medium priority since they lose priority on resumption.
    • Reserve High priority for business-critical, short-running, and infrequent flows to ensure timely execution.
    • Assign Low priority to high-volume, non-time-sensitive flows to avoid blocking more urgent processes.
    • Use Medium priority for flows with moderate time sensitivity relative to others.

    Practical Application

    ServiceNow customers should configure flow priorities thoughtfully to balance system throughput and responsiveness. Show the Flow Priority field on flow forms to easily set and adjust priorities. Monitoring the number of high-priority flows and adjusting system properties related to pausing can help manage flow execution when workloads vary.

    Specify the priority that you want a background flow to have in relation to other flows waiting to be run. Run a group of higher priority flows before running any lower priority flows.

    You can only set a flow priority for flows that run in the background. Background flows run from the next available worker thread. By default, Workflow Studio can use up to half of the available worker threads to run background flows. If there’s no available worker thread to run a flow, the flow is queued until there’s an available worker thread to run it.

    You can set background flows to have one of these priority values.
    • High
    • Medium
    • Low
    By default, background flows run with medium priority.
    Note:
    Flows that run in the foreground run in the current thread and don’t use flow priority to determine run order.

    Setting a flow priority determines the order that worker threads pick flows from the queue. Worker threads run several higher priority flows before running a lower priority flow. This priority scheme ensures that some lower priority flows get run even when there are higher priority flows in the queue. When there’s a large work queue to run, most low-priority flows must wait until the high priority flows are run. After the high priority flows have run, the worker threads can run lower priority flows.

    Should a flow remain in the queue for more than one minute, the system delegates the flow to another node to run. When a flow is delegated to another node, it loses its priority value. A delegated node pulls flows from the event queue in chronological order. The delegated node runs the oldest flows first and then runs the newest flows. Generally, delegating flows to run from another node only happens when all the available worker threads on a node are busy.
    Note:
    Worker threads run all system events, not just flow events.

    Flows also lose their priority value when they pause for any reason. Flows that resume from a pause run at the default Medium priority. For example, a flow could start running at high priority, then pauses to Wait for a Duration. When the flow resumes running, it runs at a Medium priority.

    Automatic pausing of low-priority flows

    By default, the system checks for cases where high-priority flows are being blocked by running lower priority flows. Whenever a low-priority runs for longer than two minutes, the system checks whether any higher priority flows have run in the last five minutes. If no high-priority flows have run recently, then the system checks the number of flows waiting to run in the event queue. If there’s a backlog of at least 100 high-priority flows waiting to run in the event queue, the system pauses the running low-priority flow. Pausing a flow preserves its context and data. A paused flow returns to the event queue to run when there’s a worker available to process it.

    If your low-priority flows aren’t running as expected, review the number of high-priority flows that your system generates and runs. See the design considerations for when to set a flow to high or low priority. If your low-priority flows are still not running, you can disable the pausing of low-priority with a system property. See Workflow Studio flow system properties to change the value of the com.glide.hub.pause_low_priority_flows_enabled property.

    Quick API support

    The quick API method retains the priority settings. Flows run by the quick API method run at the same priority that was previously defined for the flow.

    Design considerations

    Follow these design considerations when setting flow priority.

    Avoid setting all flows to run at high priority
    Use a mix of priorities rather than set all flows to high priority. Worker threads use the relative priority between flows to select work. If all of your flows run at high priority, then there are no lower-priority flows to make wait.
    Avoid setting flow priority for flows that have to pause
    Keep flows that have to pause at the default medium priority since a flow that pauses loses its priority value when it resumes running.
    Use high priority for business critical flows
    Limit high-priority to flows that have high business value, run rarely, and have a short runtime. Avoid setting high-volume flows to high priority as doing so limits the number of worker threads available to run other flows. A long-running high priority flow can also reduce the worker threads available to run other flows.
    Use low priority for high-volume flows
    Run high-volume flows at low priority so that other time-sensitive flows can run first. Low-priority flows shouldn't be time-sensitive.
    Use medium priority for time-sensitive flows
    Use the default flow priority when a flow has some time urgency when compared to other flows.