-
Notifications
You must be signed in to change notification settings - Fork 11.5k
Adds documentation on DO shutdown #27482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: production
Are you sure you want to change the base?
Conversation
|
This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:
|
|
Preview URL: https://1bb4f1cd.preview.developers.cloudflare.com Files with changes (up to 15) |
|
|
||
| ## Shutdown behavior | ||
|
|
||
| Durable Objects may occasionally shut down and be replaced with a new instance. This can happen for various reasons, including: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Durable Objects may occasionally shut down and be replaced with a new instance. This can happen for various reasons, including: | |
| Durable Objects will occasionally shut down and objects are restarted, which will run your Durable Object class constructor. This can happen for various reasons, including: |
|
|
||
| Durable Objects may occasionally shut down and be replaced with a new instance. This can happen for various reasons, including: | ||
|
|
||
| - New deployments with code updates |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - New deployments with code updates | |
| - New Worker [deployments](/workers/configuration/versions-and-deployments/) with code updates |
|
|
||
| - New deployments with code updates | ||
| - Updates to the Workers runtime system | ||
| - The runtime deciding to move the Durable Object to a different host |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - The runtime deciding to move the Durable Object to a different host | |
| - Workers runtime decisions on where to host objects |
| - Updates to the Workers runtime system | ||
| - The runtime deciding to move the Durable Object to a different host | ||
|
|
||
| When a Durable Object is shut down, a new instance will come up automatically to handle new requests In-flight requests are handled as follows: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| When a Durable Object is shut down, a new instance will come up automatically to handle new requests In-flight requests are handled as follows: | |
| When a Durable Object is shut down, the object instance is automatically restarted and new requests are routed to the new instance. In-flight requests are handled as follows: |
| Durable Objects may occasionally shut down and be replaced with a new instance. This can happen for various reasons, including: | ||
|
|
||
| - New deployments with code updates | ||
| - Updates to the Workers runtime system |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - Updates to the Workers runtime system | |
| - Lack of requests to an object following the state transitions documented above | |
| - Cloudflare updates to the Workers runtime system |
|
|
||
| When a Durable Object is shut down, a new instance will come up automatically to handle new requests In-flight requests are handled as follows: | ||
|
|
||
| - **HTTP requests**: Requests are allowed to finish for up to 30 seconds. However, if a request attempts to access storage during this grace period, it will be stopped immediately, since storage access is now occurring on the new instance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - **HTTP requests**: Requests are allowed to finish for up to 30 seconds. However, if a request attempts to access storage during this grace period, it will be stopped immediately, since storage access is now occurring on the new instance. | |
| - **HTTP requests**: In-flight requests are allowed to finish for up to 30 seconds. However, if a request attempts to access a Durable Object's storage during this grace period, it will be stopped immediately to maintain Durable Objects global uniqueness property. |
@joshthoward does this also apply to RPC requests?
|
|
||
| When your Durable Object code is updated, your Worker and Durable Objects are released globally in an eventually consistent manner. This will cause a Durable Object to shut down, with the behavior described above. Updates can also create a situation where a request reaches a new version of your Worker in one location, and calls to a Durable Object still running a previous version elsewhere. Refer to [Code updates](/durable-objects/platform/known-issues/#code-updates) for more information about handling this scenario. | ||
|
|
||
| ### Working without shutdown hooks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's put this in /durable-objects/best-practices/rules-of-durable-objects/#scheduling-and-lifecycle
Summary
Not sure if I got the details exactly right, but thought that information on DO shutdown would be useful
Documentation checklist