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

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
Claim ledger
Ranked by verification strength, evidence, and original report placement.
- [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]
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."
ReportedSupportedSource: Cloudflare blog2 sources— create a free account to open themView cited source - [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
- [4]
Both CPU and memory profiles can be requested from that page; the duration determines how long the profiler runs, and users can select different versions of the Worker to profile.
- [5]
"Your Worker needs plenty of traffic to be successfully profiled, so make sure you choose a version that has enough traffic."
ReportedSupportedSource: Cloudflare blog2 sources— create a free account to open themView cited source - [6]
After clicking Capture Profile, the profiler runs for the selected duration and a flamegraph is rendered. Each rectangle represents a function call, with width representing the CPU time or memory used by that function. A table view shows which functions are most commonly seen in the profile.
- [7]
TypeScript Workers should have source maps enabled, otherwise the profile may show obfuscated function names that are not easy to understand.
- [8]
Cloudflare captured a 50-second CPU profile of the Worker that implements the R2 binding. Cloudflare wrote that this Worker "receives a lot of traffic and so eliminating even the smallest amount of wasted CPU cycles can have a massive impact on its performance."
ReportedSupportedSource: Cloudflare blog2 sources— create a free account to open themView cited source - [9]
Among the widest boxes were decryptBlock, R2 decrypting object data on the way out, and fillResponse, which is moving bytes; Cloudflare saw no clear ways to optimize these functions.
- [10]
Because some boxes are less visible in the flamegraph, Cloudflare used the table view; sorting by Samples in the 50-second R2 profile pointed to genericR2JsonReplacer, which represented over 5% of CPU time and called itself recursively.
- [11]
The replacer was called by JSON.stringify on every node in the JSON tree, but the replacer itself also walked the tree, so a value nested five levels deep was processed five times.
- [12]
Fixing the duplicate work made genericR2JsonReplacer 2.7x faster.
ReportedSupportedSource: Cloudflare blog2 sources— create a free account to open themView cited source - [13]
The second candidate Cloudflare looked at in the R2 profile was a duplicate call to metrics.
- [14]
In the dashboard, users navigate Build > Compute > Workers & Pages, select a Worker, open its Observability tab and choose "Flamegraph" from a dropdown.
- [15]
If genericR2JsonReplacer took 5% of the R2 Worker's sampled CPU time and became 2.7x faster, it falls to about 1.9% of the original total, saving about 3.1% of the Worker's CPU; because the source says over 5%, 3.1% is a lower bound.
- [16]
Because each value in the R2 case was processed once per level of nesting, the wasted work grows with payload depth, so a Worker serializing flat JSON would recover little from the same fix.
Sources
1 independent publisher whose own reporting we read for this story.
- blog.cloudflare.comIntroducing on-demand CPU and memory profiling with flamegraphs for Workers and Durable Objects
1 article · October 9, 2026
- runtimewire.comCloudflare adds production flamegraphs to Workers, exposing where CPU and memory go
1 article · October 9, 2026
Topics and entities
Follow any of these and your For You feed starts watching them — no settings page required.
Topics
- Production profilingFollow
- Serverless computingFollow
- ObservabilityFollow
- FlamegraphsFollow