Skip to content

Commit 0192450

Browse files
elithrarkodster28
andauthored
limits: fix 30s vs. 5min limit (#21598)
* limits: fix 30s vs. 5min limit * workers: update CPU limit docs * missing component * Update src/content/docs/workers/platform/limits.mdx * Update src/content/docs/workers/platform/limits.mdx Co-authored-by: Kody Jackson <[email protected]> --------- Co-authored-by: kodster28 <[email protected]>
1 parent 5c86763 commit 0192450

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

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

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ head: []
77
description: Cloudflare Workers plan and platform limits.
88
---
99

10-
import { Render } from "~/components";
10+
import { Render, WranglerConfig } from "~/components";
1111

1212
## Account plan limits
1313

@@ -76,13 +76,37 @@ Cloudflare updates the Workers runtime a few times per week. When this happens,
7676

7777
### CPU time
7878

79-
CPU time is the amount of time the CPU actually spends doing work, during a given request. Most Workers requests consume less than a millisecond of CPU time. It is rare to find normally operating Workers that exceed the CPU time limit.
79+
CPU time is the amount of time the CPU actually spends doing work during a given request.
80+
If a Worker's request makes a sub-request and waits for that request to come back before
81+
doing additional work, this time spent waiting **is not** counted towards CPU time.
82+
83+
**Most Workers requests consume less than 1-2 milliseconds of CPU time**, but you can increase the maximum CPU time from the default 30 seconds to 5 minutes (300,000 milliseconds) if you have CPU-bound tasks, such as large JSON payloads that need to be serialized, cryptographic key generation, or other data processing tasks.
8084

8185
<Render file="isolate-cpu-flexibility" />
8286

83-
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.
87+
To understand your CPU usage:
88+
89+
- CPU time and Wall time are surfaced in the [invocation log](/workers/observability/logs/workers-logs/#invocation-logs) within Workers Logs.
90+
- For Tail Workers, CPU time and Wall time are surfaced at the top level of the [Workers Trace Events object](/logs/reference/log-fields/account/workers_trace_events/).
91+
- DevTools locally can help identify CPU intensive portions of your code. See the [CPU profiling with DevTools documentation](/workers/observability/dev-tools/cpu-usage/).
92+
93+
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.
94+
95+
<WranglerConfig>
96+
97+
```jsonc
98+
{
99+
// ...rest of your configuration...
100+
"limits": {
101+
"cpu_ms": 300000, // default is 30000 (30 seconds)
102+
},
103+
// ...rest of your configuration...
104+
}
105+
```
106+
107+
</WranglerConfig>
84108

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.
109+
You can also customize this in the [Workers dashboard](https://dash.cloudflare.com/?to=/:account/workers). Select the specific Worker you wish to modify -> click on the "Settings" tab -> adjust the CPU time limit.
86110

87111
:::note
88112

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Users on the Workers Paid plan have access to the Standard usage model. Workers
2828
| | Requests<sup>1, 2</sup> | Duration | CPU time |
2929
| ------------ | ------------------------------------------------------------------ | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
3030
| **Free** | 100,000 per day | No charge for duration | 10 milliseconds of CPU time per invocation |
31-
| **Standard** | 10 million included per month <br /> +$0.30 per additional million | No charge or limit for duration | 30 million CPU milliseconds included per month<br /> +$0.02 per additional million CPU milliseconds<br /><br/> Max of 30 seconds of CPU time per invocation <br /> Max of 15 minutes of CPU time per [Cron Trigger](/workers/configuration/cron-triggers/) or [Queue Consumer](/queues/configuration/javascript-apis/#consumer) invocation |
31+
| **Standard** | 10 million included per month <br /> +$0.30 per additional million | No charge or limit for duration | 30 million CPU milliseconds included per month<br /> +$0.02 per additional million CPU milliseconds<br /><br/> Max of [5 minutes of CPU time](/workers/platform/limits/#worker-limits) per invocation (default: 30 seconds)<br /> Max of 15 minutes of CPU time per [Cron Trigger](/workers/configuration/cron-triggers/) or [Queue Consumer](/queues/configuration/javascript-apis/#consumer) invocation |
3232

3333
<sup>1</sup> Inbound requests to your Worker. Cloudflare does not bill for
3434
[subrequests](/workers/platform/limits/#subrequests) you make from your Worker.
@@ -50,7 +50,7 @@ A Worker that serves 15 million requests per month, and uses an average of 7 mil
5050

5151
#### Example 2
5252

53-
A project that serves 15 million requests per month, with 80% (12 million) requests serving [static assets](/workers/static-assets/) and the remaining invoking dynamic Worker code. The Worker uses an average of 7 milliseconds (ms) of CPU time per request.
53+
A project that serves 15 million requests per month, with 80% (12 million) requests serving [static assets](/workers/static-assets/) and the remaining invoking dynamic Worker code. The Worker uses an average of 7 milliseconds (ms) of time per request.
5454

5555
Requests to static assets are free and unlimited. This project would have the following estimated costs:
5656

0 commit comments

Comments
 (0)