Cloudflare has introduced a new observability feature that allows developers to profile CPU and memory usage of Workers and Durable Objects directly in production environments. The tool generates interactive flamegraphs, providing granular visibility into resource consumption at the function level without requiring code changes or redeployment.
How the profiling tool works
The profiling system is accessible through both the Cloudflare Dashboard and a CLI. Developers can initiate a profiling session by selecting a Worker version, specifying a duration (up to 50 seconds in the examples provided), and choosing between CPU or memory profiling. The resulting flamegraph visualizes function calls as rectangles, where width corresponds to resource usage—CPU time or memory allocation. A table view is also available, sorting functions by sample count to quickly identify hotspots.
Background: Cloudflare Workers is a serverless execution environment that runs JavaScript, TypeScript, or WebAssembly at the edge. Durable Objects provide stateful coordination for Workers, enabling distributed applications with low-latency access to shared data.
For TypeScript-based Workers, source maps must be enabled to avoid obfuscated function names in the profile output. The tool targets live production traffic, meaning Workers with low request volumes may not generate usable profiles. Durable Objects can be profiled individually by name, with the runtime automatically routing the request to the correct physical server hosting the actor.
Technical implementation and limitations
The profiling system operates without pausing Worker execution. The Workers Runtime acquires an isolate lock only briefly to start or stop the profiler, releasing it during sampling to allow normal request processing. CPU profiles sample at 1-millisecond intervals, while memory profiles capture allocations within the specified window. However, the tool cannot detect allocations occurring outside the profiling duration, such as those during Worker startup.
Current limitations include the need to manually trigger profiling sessions, which may miss transient performance issues. Cloudflare has acknowledged these constraints and is developing a continuous profiling feature to automatically capture samples for later analysis.
Practical use cases and optimizations
Cloudflare’s internal teams have already used the tool to identify and resolve performance bottlenecks. In one case, profiling revealed a recursive function in an R2 binding Worker that was processing JSON nodes multiple times. Fixing this redundancy reduced CPU usage by 2.7x for the affected function. Another optimization eliminated a duplicate metrics call that accounted for 1% of CPU time in a high-traffic Worker.
A separate internal Worker with frequent "Exceeded Memory" errors was diagnosed using heap profiling. The tool exposed that partially disabled Prometheus instrumentation was consuming 66.7% of allocations, despite not exporting data. Removing the code entirely reduced P999 memory usage from 133 MB to 118 MB, providing headroom below the 128 MB limit.
For professionals: On-demand profiling enables edge-specific debugging without local emulation. Teams can now validate optimizations under real-world traffic patterns, particularly for Durable Objects where stateful behavior may differ across deployments. The tool’s integration with existing observability dashboards reduces context-switching for performance investigations.
Companies mentioned
Automated pipeline · SaaS
Synthesized from 1 industry feed on 9 Oct 2026. Passed independent editor verification (score 95/100) before publication. Style guide v1.4.
Sources
Decision trail
- Checking for duplicates — Deduped batch of 2 candidates
- Checking for duplicates — New story No existing article covers Cloudflare's on-demand CPU/memory profiling for Workers/Durable Objects.
- Checking for duplicates — New story pre_write:; No existing article covers Cloudflare's on-demand CPU/memory profiling for Workers/Durable Objects.
- Writing the article — Draft created article_id=675 slug=cloudflare-adds-on-demand-profiling-for-workers
-
Editor review — Approved
- Score: 95/100
- Style compliance: Headline exceeds 90-character limit (92 characters).
- Factual grounding: Background block states 'Durable Objects provide stateful coordination for Workers' — while correct, the phrasing closely mirrors source wording ('Durable Objects are stateful'). Restructure to avoid echoing source phrasing.
- No copied phrasing: Section 'Technical implementation and limitations' uses 'isolate lock' and 'profiling session' phrasing that appears verbatim in the source. Rephrase to avoid echoing source wording.
- Generating reader Q&A — Generated 5 items
- Assigning hero image — Rejected library image #20: The candidate depicts an electrical substation and transmission lines, which is unrelated to Cloudflare Workers, serverless computing, or flamegraphs. The alt text and query do not match the article topic (developer tools, CPU/memory profiling, or serverless code debugging).
- Assigning hero image — Rejected library image #140: The candidate depicts the GoDaddy headquarters exterior (as indicated by the alt text), which is unrelated to Cloudflare, serverless computing, or profiling tools. The URL slug and metadata do not match the article topic, and the image is not relevant to the developer tools or Cloudflare context.
- Assigning hero image — Unsplash unsplash_id=phS1wAgXOQI q=CPU and memory profiling dashboard picker=The candidate directly depicts a CPU and memory profiling dashboard, which aligns perfectly with the article's focus on
- Linking related stories — Linked 5 relations from 338 candidates
- Publishing — Published cloudflare-adds-on-demand-profiling-for-workers
- Mastodon — Posted https://mstdn.social/@hostingpaper/117411517655851301




Discussion · coming soon
Be the first to join the thread when community discussion launches.