Skip to content

Commit 4db44e9

Browse files
Rewrite Workers Memory Limits docs (#19049)
* Rewrite Workers Memory Limits docs * Update src/content/docs/workers/platform/limits.mdx Co-authored-by: Steve Faulkner <[email protected]> * Update src/content/docs/workers/platform/limits.mdx --------- Co-authored-by: Steve Faulkner <[email protected]>
1 parent c98c6a7 commit 4db44e9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,17 +176,19 @@ Routes in fail closed mode will display a Cloudflare `1027` error page to visito
176176

177177
## Memory
178178

179-
Only one Workers instance runs on each of the many global Cloudflare global network servers. Each Workers instance can consume up to 128 MB of memory. Use [global variables](/workers/runtime-apis/web-standards/) to persist data between requests on individual nodes. Note however, that nodes are occasionally evicted from memory.
179+
Each [isolate](/workers/reference/how-workers-works/#isolates) of your Worker's code runs in can consume up to 128 MB of memory. This includes both memory used by the JavaScript heap, and memory explicitly allocated in [WebAssembly](/workers/runtime-apis/webassembly/). Note that this limit is per-isolate, not per-invocation of your Worker. A single isolate can handle many concurrent requests.
180180

181-
If a Worker processes a request that pushes the Worker over the 128 MB limit, the Cloudflare Workers runtime may cancel one or more requests. To view these errors, as well as CPU limit overages:
181+
When an isolate running your Worker exceeds 128 MB of memory, the Workers runtime handles this gracefully instead of failing immediately. It allows in-flight requests to complete while simultaneously creating a new isolate for your Worker for new requests. While this approach typically allows in-flight requests to complete, during periods of extremely high load, some incoming requests may be cancelled to maintain system stability.
182+
183+
To view out-of-memory errors (OOM), as well as CPU limit overages:
182184

183185
1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com) and select your account.
184186
2. Select **Workers & Pages** and in **Overview**, select the Worker you would like to investigate.
185187
3. Under **Metrics**, select **Errors** > **Invocation Statuses** and examine **Exceeded Memory**.
186188

187-
Use the [TransformStream API](/workers/runtime-apis/streams/transformstream/) to stream responses if you are concerned about memory usage. This avoids loading an entire response into memory.
189+
To avoid exceeding memory limits, where possible you should avoid buffering large objects or responses in memory, and instead use streaming APIs such as [`TransformStream`](/workers/runtime-apis/streams/transformstream/) or [`node:stream`](/workers/runtime-apis/nodejs/streams/) to stream responses. Manipulating streams allows you to avoid buffering entire responses in memory.
188190

189-
Using DevTools locally can help identify memory leaks in your code. See the [memory profiling with DevTools documentation](/workers/observability/dev-tools/memory-usage/) to learn more.
191+
You can also use Chrome DevTools in local development to identify memory leaks in your code. See the [memory profiling with DevTools documentation](/workers/observability/dev-tools/memory-usage/) to learn more.
190192

191193
---
192194

0 commit comments

Comments
 (0)