Cloudflare announced support for on-demand CPU and memory profiling and interactive flamegraphs for Workers and Durable Objects. The new feature allows developers to profile active applications directly in production.
Production Profiling and Flamegraphs
Cloudflare said the new profiling capability allows users to request an on-demand CPU or memory profile of an active Worker from the Workers Observability page. Developers can inspect the results as an interactive flamegraph or download the profile file for further analysis.
According to Cloudflare, the runtime holds the isolate lock only for profiler lifecycle operations to ensure applications can continue executing while samples are collected.
Accessing via CLI and Dashboard
To use the CLI, Cloudflare states users must have the cf package installed and run the specified profile command with a worker ID, duration, and profile type. Alternatively, users can navigate to the Cloudflare dashboard under Build, Compute, Workers & Pages, and select Observability.
Cloudflare noted that developers can also trigger profiles using the API, specifying the script name and version in the request URL.
What to do
- To use the CLI, ensure the cf package is installed and run the profile command with your worker ID, duration, and profile type.
- To use the dashboard, navigate to Build, Compute, Workers & Pages, select your Worker, and open its Observability tab to select Flamegraph.
- If your Worker is implemented in TypeScript, ensure source maps are enabled for your project.
Key facts and where they come from
- Cloudflare announced support for CPU and memory profiling of Workers and Durable Objects.
Today we are happy to announce support for CPU and memory profiling of Workers and Durable Objects.
- Users can request profiles from the Workers Observability page or via the CLI.
From the Workers Observability page, you can now request an on-demand CPU or memory profile of an active Worker
- The runtime holds the isolate lock only for profiler lifecycle operations during profiling.
The Workers Runtime therefore holds the isolate lock only for profiler lifecycle operations.
