Lifecycle of a Durable Object

There was a discussion around this recently. The consensus was that outgoing WebSocket connections prevented the DO from entering the "Idle, In-memory, & Hibernatable state" eventhough it's not listed as one of the three conditions that would do that in Lambros' awesome lifecycle diagram: https://developers.cloudflare.com/durable-objects/concepts/durable-object-lifecycle/. I don't think we ever got a definitive answer on that thread. Someone is going to have to run an experiment.
Cloudflare Docs
Lifecycle of a Durable Object
This section describes the lifecycle of a Durable Object.
5 Replies
Avi
Avi2d ago
super helpful diagram, thanks for pointing me to that! in our case, we are of course always in the 'idle' state
Larry
LarryOP2d ago
Huh? by sending every 100ms, you are toggling between the active and one of the two idle states, I believe?
Avi
Avi2d ago
no, it only enters idle+hibernateable after 10 seconds that's why the hibernation API is useless for us we never let the connection idle that long in our case, we always remain in the active state
Larry
LarryOP2d ago
The 10-second delay is for going to "hibernated" not "hibernatable". It immediately goes to idle as soon as the message is done being sent or processed. Either of those should be well short of 100ms.
Avi
Avi2d ago
yes, and thus we don't get the benefit of being hibernated... sending more frequently than once per 10seconds means the DO will never enter Hibernated state you're right that it enters the hibernateable state... but this is just another idle state, equivalent to being and idle but non-hibernateable so there is no benefit
no, it only enters idle+hibernateable after 10 seconds
ahh, i see now that i did say this, which is wrong i should have said it only enters hibernation after 10s

Did you find this page helpful?