Cloudflare Workers gets on-demand production profiling
A new flamegraph tool captures live CPU and memory profiles from a running Worker or Durable Object, no redeploy needed.
Cloudflare launched on-demand CPU and memory profiling for Workers and Durable Objects on 9 October. You can request a profile of a live, actively running Worker from the dashboard or the CLI, and get back an interactive flamegraph rather than a static log line.
The CLI takes a worker ID and a capture duration:
cf workers versions profile latest \
--worker-id "$WORKER_ID_OR_NAME" \
--duration-ms 5000 \
--profile-type cpu > worker-cpu.pprof
Captures run between 1,000ms and 50,000ms, defaulting to 10,000ms, and the API rate-limits repeated requests. Cloudflare’s own examples: profiling an R2 binding Worker found a recursive JSON replacer wasting 2.7x the CPU it needed, and profiling an internal Worker traced a memory leak to incompletely disabled Prometheus instrumentation that was pushing it toward the 128MB Worker memory limit.
Why it matters: debugging a slow or leaking Worker in production used to mean adding logging and redeploying. This gets you a flamegraph of the actual running isolate without touching the code, which matters most for Durable Objects, where state lives in the instance and you can’t always reproduce the problem locally.