Hmm is there some documentation

Hmm is there some documentation detailing this? If we can't make reliable assumptions about memory availability with > 1 DO namespace instance that seems problematic.
3 Replies
Larry
Larry•4mo ago
In this official documention it mentions the memory sharing but not the implication that the total consumption for all instances that share memory cannot exceed 128MB: https://developers.cloudflare.com/durable-objects/reference/in-memory-state/
Cloudflare Docs
In-memory state in a Durable Object · Cloudflare Durable Objects docs
In-memory state means that each Durable Object has one active instance at any particular time. All requests sent to that Durable Object are handled by that same instance. You can store some state in memory.
Larry
Larry•4mo ago
However, the instance sharing has been discussed here many times. Here is a linkk to one such reference: https://community.cloudflare.com/t/durable-object-shared-memory-allocation-wasm/572293 I did some experiments by setting a global variable and loged how often instances end up in the same memory space and it was rare and never more than 2 for my load. That said, I have never read a great discussion about how likely it is and how many is the likely max. That caused me to design my DOs to be stingy with memory which isn't as big of a problem as I thought it would be because the storage is so fast and cached. Now, I don't keep large structures in instance variables. If I need them, I fetch them from storage on every request and release the memory when the request is over.
peachneo
peachneoOP•4mo ago
that makes sense, good to know - appreciate the heads up 🙂

Did you find this page helpful?