Skip to content

BuildNot yet confirmed elsewhere1 publisher2 min readPublished

Cloudflare adds on-demand production profiling for Workers and Durable Objects

Cloudflare now lets Workers and Durable Objects users take on-demand CPU and memory profiles in production and view them as flamegraphs. Each capture runs for a window the user sets and can be saved from the CLI to a .pprof file for further analysis.

The Engineer · Build desk

How we use AISend a correction

Illustration accompanying Cloudflare adds on-demand production profiling for Workers and Durable Objects
Generated illustration

What happened

  • Cloudflare says a Worker needs plenty of traffic to be profiled successfully, so the version chosen for a capture has to be receiving enough requests.
  • A 50-second CPU profile of the Worker behind the R2 binding showed a function called genericR2JsonReplacer taking over 5% of CPU time and calling itself recursively.
  • Removing the duplicate work inside that replacer made it 2.7x faster, according to Cloudflare.
  • TypeScript Workers need source maps enabled, or the profile may show obfuscated function names that are hard to read.

Compiled by The EngineerSomething wrong?How this is made

Why it matters

  • capability Teams chasing OOM errors or CPU spend on Workers can attribute it to a specific function in production, past the point where Cloudflare says logs and aggregate metrics stop helping.
  • constraint A new version on a small slice of a gradual rollout may not draw enough requests to profile, so the newest code can be the hardest to inspect.
  • decision Fixes are worth ranking by their share of the profile: Cloudflare's 2.7x function speedup comes to about 3% of the R2 Worker's CPU.

In the dashboard the profiler sits under Build > Compute > Workers & Pages. It is on each Worker's Observability tab, behind a "Flamegraph" option in a dropdown [14]. You choose a duration and a version, press Capture Profile, and the graph renders once the profiler has run for that long [4][6]. Each rectangle is a function call. Its width is the CPU time or memory that function used [6]. The CLI does the same in one command. The documented example passes `--duration-ms 5000` and `--profile-type cpu` for the latest version and redirects the output to a file [3].

The announcement covers Durable Objects alongside Workers [1]. Every step in the walkthrough, including the CLI's `--worker-id` flag, is written for a Worker [3][14].

The R2 example is the most useful part of the post. Cloudflare profiled the Worker behind the R2 binding, a high-traffic service, for 50 seconds [8]. The widest boxes were decryptBlock, which decrypts object data on the way out, and fillResponse, which moves bytes [9]. Cloudflare found no clear way to optimize either [9]. A storage service should be spending its CPU on those two jobs. The lead came from the table view sorted by samples, which Cloudflare recommends because some boxes are hard to see in the graph [10]. The second candidate was a duplicate call to metrics [13].

The 2.7x is a function-level figure. A function holding 5% of CPU that runs 2.7x faster drops to about 1.9% of the original total. That saves about 3.1% of the Worker's sampled CPU time [15]. The post puts the function at over 5%, so 3.1% is a floor [15]. Cloudflare wrote that on this Worker "eliminating even the smallest amount of wasted CPU cycles can have a massive impact on its performance." [8]

Two conditions decide whether that gain transfers to another team's Worker. The code needs the same mistake: a replacer that walks the tree itself while JSON.stringify is already calling it on every node [11]. The payloads also need depth. In Cloudflare's case a value nested five levels deep was processed five times, so passes per value tracked nesting depth [11]. A Worker serializing flat objects would recover little from the same fix [16].

The post does not say what a capture costs in overhead on a live Worker, how often the profiler samples, or which plans include it.

What to watch

  • Whether Cloudflare's docs publish the profiler's overhead and sampling interval for captures on live Workers.
  • A Durable Objects-specific workflow or CLI flag, since the current steps target Workers by --worker-id.
  • Whether profiles can be triggered automatically, for example on an OOM error, instead of only on demand.

Clarity's read

What the record supports and how the coverage leans. The claims behind it follow.

Reality

Evidence60
Adoption20
Hype gap+5
Incentives65
Confidence70
Why these scores

Claim ledger

Ranked by verification strength, evidence, and original report placement.

  1. [1]

    Cloudflare announced support for CPU and memory profiling of Workers and Durable Objects. From the Workers Observability page, users can request an on-demand CPU or memory profile of an active Worker, inspect it as an interactive flamegraph, and download the profile file for further analysis.

  2. [2]

    Cloudflare wrote: "Logs and aggregate metrics can only get you so far." It also wrote that "the best way to understand your application is to profile it in production."

  3. [3]

    With the cf package installed, a CPU profile can be captured via the CLI with: cf workers versions profile latest --worker-id "$WORKER_ID_OR_NAME" --duration-ms 5000 --profile-type cpu > worker-cpu.pprof

Sources

1 independent publisher whose own reporting we read for this story.

  1. blog.cloudflare.com

    1 article · October 9, 2026

    Introducing on-demand CPU and memory profiling with flamegraphs for Workers and Durable Objects
  2. runtimewire.com

    1 article · October 9, 2026

    Cloudflare adds production flamegraphs to Workers, exposing where CPU and memory go

Share your take

Let Clarity write the post for you.

Signed-in readers get a short post drafted on this story in the register they choose — narrative, analytical, or a direct position — editable to the last word before it goes anywhere. The share buttons at the top of this story work without an account.

Topics and entities

Follow any of these and your For You feed starts watching them — no settings page required.

Loading related stories