Skip to content

Commit a64cb67

Browse files
authored
durable objects: cpu time updates #21135
1 parent 6e8a703 commit a64cb67

File tree

1 file changed

+22
-2
lines changed
  • src/content/docs/durable-objects/platform

1 file changed

+22
-2
lines changed

src/content/docs/durable-objects/platform/limits.mdx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ Durable Objects are only available on the [Workers Paid plan](/workers/platform/
2020
| Key size | 2 KiB (2048 bytes) | Key and value combined cannot exceed 2 MB |
2121
| Value size | 128 KiB (131072 bytes) | Key and value combined cannot exceed 2 MB |
2222
| WebSocket message size | 1 MiB (only for received messages) | 1 MiB (only for received messages) |
23-
| CPU per request | 30s (including WebSocket messages) [^4] | 30s (including WebSocket messages) [^4] |
23+
| CPU per request | 30s (including WebSocket messages) [^4] | 30 seconds (default) / configurable to 5 minutes of [active CPU time](/workers/platform/limits/#cpu-time) [^4] |
2424

2525
[^1]: The new beta version of Durable Objects is available where each Durable Object has a private, embedded SQLite database. When creating a Durable Object class, users can [opt-in to using SQL storage](/durable-objects/reference/durable-objects-migrations/#enable-sqlite-storage-backend-on-new-durable-object-class-migration).
2626

2727
[^2]: Durable Objects both bills and measures storage based on a gigabyte <br/> (1 GB = 1,000,000,000 bytes) and not a gibibyte (GiB). <br/>
2828

2929
[^3]: Will be raised to 10 GB for general availability.
3030

31-
[^4]: Each incoming HTTP request or WebSocket *message* resets the remaining available CPU time to 30 seconds. This allows the Durable Object to consume up to 30 seconds of compute after each incoming network request, with each new network request resetting the timer. If you consume more than 30 seconds of compute between incoming network requests, there is a heightened chance that the individual Durable Object is evicted and reset.
31+
[^4]: Each incoming HTTP request or WebSocket *message* resets the remaining available CPU time to 30 seconds. This allows the Durable Object to consume up to 30 seconds of compute after each incoming network request, with each new network request resetting the timer. If you consume more than 30 seconds of compute between incoming network requests, there is a heightened chance that the individual Durable Object is evicted and reset.
3232

3333
For Durable Object classes with [SQLite storage backend](/durable-objects/best-practices/access-durable-objects-storage/#sqlite-storage-backend) these SQL limits apply:
3434

@@ -63,3 +63,23 @@ Durable Objects are designed such that the number of individual objects in the s
6363
- You can create and run as many separate Durable Objects as you want within a given Durable Object <GlossaryTooltip term="namespace">namespace</GlossaryTooltip>.
6464
- The main limit to your usage of Durable Objects is the total storage limit per account.
6565
- If you need more storage, contact your account team or complete the [Limit Increase Request Form](https://forms.gle/ukpeZVLWLnKeixDu7) and we will contact you with next steps.
66+
67+
### Increasing Durable Object CPU limits
68+
69+
Durable Objects are Worker scripts, and share the same [per invocation CPU limits](/workers/platform/limits/#worker-limits) as any Workers do. Note that CPU time is active processing time: not time spent waiting on network requests, storage calls, or other general I/O, which don't count towards your CPU time or Durable Objects compute consumption.
70+
71+
By default, the maximum CPU time per Durable Objects invocation (HTTP request, WebSocket message, or Alarm) is set to 30 seconds, but can be increased for all Durable Objects associated with a Durable Object definition by setting `limits.cpu_ms` in your wrangler configuration:
72+
73+
<WranglerConfig>
74+
75+
```jsonc
76+
{
77+
// ...rest of your configuration...
78+
"limits": {
79+
"cpu_ms": 300000, // 300,000 milliseconds = 5 minutes
80+
},
81+
// ...rest of your configuration...
82+
}
83+
```
84+
85+
</WranglerConfig>

0 commit comments

Comments
 (0)