Cloudflare adds on-demand CPU and memory flamegraph profiling for Workers
Cloudflare launched on-demand CPU and memory profiling with flamegraphs for Workers and Durable Objects, available via the cf CLI or the dashboard.
Before you start: versions, package names and storage identifiers change over time. Check the commands against the official documentation for your setup before running them, especially anything that creates, deletes or overwrites data.
Cloudflare now lets you request an on-demand CPU or memory profile of a running Worker or Durable Object and inspect the result as an interactive flamegraph. The company announced the feature on October 9, 2026, in a post by Dominik Picheta, and it is available from the Workers Observability page.
The pitch is simple: logs and aggregate metrics tell you that something is expensive, but not which function is burning the CPU or allocating the memory. A profile points at the exact function, captured against real production traffic rather than a synthetic test.
Two ways to capture a profile
You can trigger a capture from the CLI or the Cloudflare dashboard. With the cf package installed, the command is:
cf workers versions profile latest --worker-id "$WORKER_ID_OR_NAME" --duration-ms 5000 --profile-type cpu > worker-cpu.pprof
In the dashboard, go to Build → Compute → Workers & Pages, pick your Worker, open its Observability tab and choose “Flamegraph” from the drop-down. From there you can request both CPU and memory profiles, set how long the profiler runs, and choose which version of the Worker to profile. Cloudflare notes that your Worker needs plenty of traffic for a profile to succeed, so pick a version that is actually receiving requests.
Once you hit Capture Profile, the profiler runs for the selected duration and renders a flamegraph. Each rectangle is a function call, and its width represents the CPU time or memory that function used. You can click a function to focus on it and hover for more detail, or switch to the table view for a quick look at which functions appear most often.
Source maps matter for TypeScript Workers
If your Worker is written in TypeScript, enable source maps for the project. Without them, the profile can show obfuscated function names that are hard to read.
Cloudflare says several internal teams have already used CPU and memory profiling to find optimization opportunities, fix out-of-memory errors and improve performance. One example in the post is the Worker implementing the R2 binding, profiled for 50 seconds of CPU traces; the widest boxes included decryptBlock, which handles R2 decrypting object data on the way out, and fillResponse, which moves bytes.
Profiles can also be downloaded as a file for further analysis outside the dashboard.
Related reading
Sources
- Introducing on-demand CPU and memory profiling with flamegraphs for Workers and Durable Objects — Cloudflare Blog
Some links on this page may be affiliate links. If you buy through them we may earn a commission at no extra cost to you. See our affiliate disclosure.