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
super helpful diagram, thanks for pointing me to that! in our case, we are of course always in the 'idle' state
Huh? by sending every 100ms, you are toggling between the active and one of the two idle states, I believe?
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
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.
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 secondsahh, i see now that i did say this, which is wrong i should have said it only enters hibernation after 10s