policy
platform_limits
ai_generated
partial
Cloudflare Worker exceeds CPU time limit even though wall clock time is well under 30s
ID: policy/cloudflare-workers-cpu-time-limit
72%Fix Rate
82%Confidence
3Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| any | active | — | — | — |
Root Cause
Cloudflare Workers free tier has 10ms CPU time limit (not wall clock time). A request waiting 5s for a fetch() uses ~0ms CPU. But JSON.parse() on a large payload or crypto operations quickly exceed 10ms CPU. Paid plan gets 30s wall clock.
genericWorkarounds
-
90% success Move CPU-intensive work to a backend service, use Worker only for routing/transformation
Worker fetches from origin/backend, does minimal transformation, returns result. Heavy computation stays in backend.
-
88% success Upgrade to Workers Paid ($5/month) for 30s wall clock / 30ms CPU per request
Paid Workers: 30s wall clock for HTTP, 15min for Cron Triggers. Much more generous CPU limits.
-
82% success Use streaming responses to avoid large JSON parse operations
Use HTMLRewriter or streaming JSON parser instead of loading entire response into memory
Dead Ends
Common approaches that don't work:
-
Assume 10ms means the Worker must complete in 10 milliseconds wall clock time
85% fail
CPU time ≠ wall clock time. I/O wait (fetch, KV reads) doesn't count. A Worker can run for 30s wall clock if most time is I/O, but 10ms of pure computation is the limit.
-
Optimize fetch calls to reduce total execution time
78% fail
fetch() is I/O and doesn't count toward CPU time. The bottleneck is usually JSON parsing, string manipulation, or crypto operations.