|
7 | 7 | description: Cloudflare Workers plan and platform limits. |
8 | 8 | --- |
9 | 9 |
|
10 | | -import { Render } from "~/components"; |
| 10 | +import { Render, WranglerConfig } from "~/components"; |
11 | 11 |
|
12 | 12 | ## Account plan limits |
13 | 13 |
|
@@ -76,13 +76,37 @@ Cloudflare updates the Workers runtime a few times per week. When this happens, |
76 | 76 |
|
77 | 77 | ### CPU time |
78 | 78 |
|
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. |
80 | 84 |
|
81 | 85 | <Render file="isolate-cpu-flexibility" /> |
82 | 86 |
|
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> |
84 | 108 |
|
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. |
86 | 110 |
|
87 | 111 | :::note |
88 | 112 |
|
|
0 commit comments