Skip to content

Performance Megathread - Is your workflow run slow? Look here first #1930

@VaguelySerious

Description

@VaguelySerious

This issue gathers all known performance issues that are NOT due to edge-cases.

If your workflow performs well in most cases, but hits performance problems in some cases, please open a separate issue, and optionally link it here.

Known bottlenecks

Replay invocation overhead

Between every step, the workflow enqueues an event replay. This means invocation overhead, queue overhead, and initial state fetching overhead on each step call.

Replay event fetching overhead

Event payload overhead

  • All step inputs, outputs, and hook inputs need to be serialized and loaded on every replay. Many common operations e.g. passing step outputs into new steps frequently when modifying a large data structure, accumulate copies of this data structure, which can easily lead to
    • Compressing data before storing them can reduce this overhead by 80% for most json/string based payloads. This should be handled by the World, and is WIP, see RFC: gzip-compress serialized payload refs (specVersion 5) #2394.
    • When a step output is passed as a step input, or similar re-use of payloads, the runtime should detect this and de-duplicate by passing references only. This requires further thinking and is not currently in progress.
      • Alternatively, the runtime could store diffs only, and merge them at replay time. This requires further thinking and is not currently in progress.

Cold starts

Workflow "use workflow" and "use step" functions get bundled separately (< 5.0.0-beta.5) or as one bundle (>= 5.0.0-beta.5), each of which can incur cold starts separate from the API bundles that start the workflows.

The best ways to reduce this overhead are:

  • Reduce bundle size
  • Pre-warm functions
    • On Vercel, using Fluid compute (highly recommended) will intelligently pre-warm your functions (and reduce costs)
  • Use >= 5.0.0-beta.5 to half the amount of bundles that need to be warm

Cross-region networking

Your app, workflow runtime, and DB should all run in the same network region.

As of May 5, 2026, workflows run against iad1 (us-east), so it's recommended to run your workflow-enabled app and the connected databases or other services in the same region. See #1931 for updates.


A note on pre-releases

Performance improvements go through a QA phase before being released as 5.x..x-beta releases currently. If you want the latest improvements now, considering using pre-releases (nightly build) by installing tarballs from https://workflow-tarballs.labs.vercel.dev/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions