Skip to content

Commit bf77f14

Browse files
mikenomitchrita3koirvinebroque
authored
Adds changelog entry for cpu_ms limit bump (#21112)
* Adds changelog entry for cpu_ms limit bump * update limits page * Update src/content/changelog/workers/2025-03-25-higher-cpu-limits.mdx Co-authored-by: Brendan Irvine-Broque <[email protected]> * clarify wall clock vs cpu time * mention workflows & queues --------- Co-authored-by: Rita Kozlov <[email protected]> Co-authored-by: Rita Kozlov <[email protected]> Co-authored-by: Brendan Irvine-Broque <[email protected]>
1 parent 2dd3592 commit bf77f14

File tree

3 files changed

+55
-3
lines changed

3 files changed

+55
-3
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
title: Run Workers for up to 5 minutes of CPU-time
3+
description: Workers now support up to 5 minutes of CPU time per request. Allowing more CPU-intensive workloads.
4+
products:
5+
- workers
6+
date: 2025-03-26T17:00:00Z
7+
---
8+
9+
import { Render, TypeScriptExample, WranglerConfig } from "~/components";
10+
11+
You can now run a Worker for up to 5 minutes of CPU time for each request.
12+
13+
Previously, each Workers request ran for a maximum of 30 seconds of CPU time — that is the time that a Worker is actually performing a task (we still allowed unlimited wall-clock time, in case you were waiting on slow resources). This
14+
meant that some compute-intensive tasks were impossible to do with a Worker. For instance,
15+
you might want to take the cryptographic hash of a large file from R2. If
16+
this computation ran for over 30 seconds, the Worker request would have timed out.
17+
18+
By default, Workers are still limited to 30 seconds of CPU time. This protects developers
19+
from incurring accidental cost due to buggy code.
20+
21+
By changing the `cpu_ms` value in your Wrangler configuration, you can opt in to
22+
any value up to 300,000 (5 minutes).
23+
24+
<WranglerConfig>
25+
26+
```jsonc
27+
{
28+
// ...rest of your configuration...
29+
"limits": {
30+
"cpu_ms": 300000,
31+
},
32+
// ...rest of your configuration...
33+
}
34+
```
35+
36+
</WranglerConfig>
37+
38+
:::note
39+
CPU time is the amount of time the CPU actually spends doing work during a given request.
40+
If a Worker's request makes a sub-request and waits for that request to come back before
41+
doing additional work, this time spent waiting **is not** counted towards CPU time.
42+
43+
Worker requests could run for more than 30 seconds of total time prior to this change — only
44+
CPU time was limited.
45+
:::
46+
47+
For more information on the updates limits, see the documentation on [Wrangler configuration for `cpu_ms`](/workers/wrangler/configuration/#limits)
48+
and on [Workers CPU time limits](/workers/platform/limits/#cpu-time).
49+
50+
For building long-running tasks on Cloudflare, we also recommend checking out [Workflows](/workflows/) and [Queues](/queues/).

src/content/docs/workers/platform/limits.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Cloudflare does not enforce response limits on response body sizes, but cache li
6262
| ------------------------ | ------------------------------------------ | ---------------- |
6363
| [Request](#request) | 100,000 requests/day<br/>1000 requests/min | No limit |
6464
| [Worker memory](#memory) | 128 MB | 128 MB |
65-
| [CPU time](#cpu-time) | 10 ms | 30 s HTTP request <br/> 15 min [Cron Trigger](/workers/configuration/cron-triggers/) |
65+
| [CPU time](#cpu-time) | 10 ms | 5 min HTTP request <br/> 15 min [Cron Trigger](/workers/configuration/cron-triggers/) |
6666
| [Duration](#duration) | No limit | No limit for Workers. <br/>15 min duration limit for [Cron Triggers](/workers/configuration/cron-triggers/), [Durable Object Alarms](/durable-objects/api/alarms/) and [Queue Consumers](/queues/configuration/javascript-apis/#consumer) |
6767

6868
### Duration
@@ -82,7 +82,7 @@ CPU time is the amount of time the CPU actually spends doing work, during a give
8282

8383
Using DevTools locally can help identify CPU intensive portions of your code. See the [CPU profiling with DevTools documentation](/workers/observability/dev-tools/cpu-usage/) to learn more.
8484

85-
You can also set a custom limit on the amount of CPU time that can be used during each invocation of your Worker. To do so, navigate to the Workers section in the Cloudflare dashboard. Select the specific Worker you wish to modify, then click on the "Settings" tab where you can adjust the CPU time limit.
85+
You can also set a [custom limit](/workers/wrangler/configuration/#limits) on the amount of CPU time that can be used during each invocation of your Worker. To do so, navigate to the Workers section in the Cloudflare dashboard. Select the specific Worker you wish to modify, then click on the "Settings" tab where you can adjust the CPU time limit.
8686

8787
:::note
8888

src/content/docs/workers/wrangler/configuration.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,9 @@ watch_dir = "build_watch_dir"
398398

399399
## Limits
400400

401-
You can impose limits on your Worker's behavior at runtime. Limits are only supported for the [Standard Usage Model](/workers/platform/pricing/#example-pricing-standard-usage-model). Limits are only enforced when deployed to Cloudflare's network, not in local development. The CPU limit can be set to a maximum of 30,000 milliseconds (30 seconds).
401+
You can impose limits on your Worker's behavior at runtime. Limits are only supported for the [Standard Usage Model](/workers/platform/pricing/#example-pricing-standard-usage-model).
402+
Limits are only enforced when deployed to Cloudflare's network, not in local development. The CPU limit
403+
can be set to a maximum of 300,000 milliseconds (5 minutes).
402404

403405
<Render file="isolate-cpu-flexibility" /> <br />
404406

0 commit comments

Comments
 (0)