[DO] Document outbound connections keep Durable Objects alive#31324
[DO] Document outbound connections keep Durable Objects alive#31324iglesiasbrandon wants to merge 5 commits into
Conversation
|
This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:
|
There was a problem hiding this comment.
Reviewed 5 files. 4 issues need addressing before merge.
MEDIUM — Style guide and accuracy:
- line 9: Spell out LLM on first use per the style guide.
- line 11: 'keepalive token' is an implementation detail; describe behavior instead.
- line 70: 'remains in-memory' should be 'remains in memory' (hyphenate compound modifiers only before a noun).
- line 192: Parenthetical grammar is awkward; rephrase.
|
Review posted on PR #31324. Labels: Already correctly labeled with Summary: This PR documents the May 2026 behavior change where active outbound TCP sockets ( Issues flagged: 4 inline suggestions posted.
|
…ections-keep-dos-alive.mdx Co-authored-by: ask-bonk[bot] <249159057+ask-bonk[bot]@users.noreply.github.com>
…ections-keep-dos-alive.mdx Co-authored-by: ask-bonk[bot] <249159057+ask-bonk[bot]@users.noreply.github.com>
…ycle.mdx Co-authored-by: ask-bonk[bot] <249159057+ask-bonk[bot]@users.noreply.github.com>
Co-authored-by: ask-bonk[bot] <249159057+ask-bonk[bot]@users.noreply.github.com>
irvinebroque
left a comment
There was a problem hiding this comment.
- Can we get a diagram here that shows this — like how we did one for this? #29722 (comment)
- can we explain/show in context of building agents on cloudflare?
| date: 2026-06-19 | ||
| --- | ||
|
|
||
| Durable Objects now remain alive for the duration of active outbound connections created via [`connect()`](/workers/runtime-apis/tcp-sockets/) or an outbound WebSocket. Previously, the routing supervisor would evict a Durable Object after 70-140 seconds of no incoming traffic, even if the object had an open outbound connection — a common pattern when streaming responses from a large language model (LLM) or other long-lived upstream API. |
There was a problem hiding this comment.
What about connections to Hyperdrive or other bindings?
| date: 2026-06-19 | ||
| --- | ||
|
|
||
| Durable Objects now remain alive for the duration of active outbound connections created via [`connect()`](/workers/runtime-apis/tcp-sockets/) or an outbound WebSocket. Previously, the routing supervisor would evict a Durable Object after 70-140 seconds of no incoming traffic, even if the object had an open outbound connection — a common pattern when streaming responses from a large language model (LLM) or other long-lived upstream API. |
There was a problem hiding this comment.
"routing supervisor"
^ very internal language
|
|
||
| With this change, each active outbound connection prevents eviction. Once all outbound connections close, the standard 70-140 second inactivity window applies before the Durable Object is evicted. | ||
|
|
||
| This applies to outbound TCP sockets (`connect()`) and outbound WebSockets, including a `fetch()` request upgraded to a WebSocket via `Upgrade: websocket`. Plain `fetch()` subrequests never keep a Durable Object alive — they are pass-through and have no effect on DO lifetime, even while the response body is still streaming. |
There was a problem hiding this comment.
Above we are talking about LLM calls - but here we are saying your DO can get terminated even if just waiting on fetch() to an LLM - which is it?
|
|
||
| **Limits:** | ||
|
|
||
| - Each outbound connection pins the Durable Object for a maximum of **15 minutes**. After 15 minutes, the connection stops preventing eviction (the connection itself continues operating), and normal eviction rules resume. |
There was a problem hiding this comment.
Define "pins" or use more precise language?
There was a problem hiding this comment.
"normal eviction rules" — as a customer how do I know what these are? where do i look?
Summary
Documents the behavior change shipped in May 2026 where active outbound connections (TCP
connect()and outbound WebSockets) now keep a Durable Object alive and prevent eviction for the duration of the connection, up to a 15-minute per-connection cap.Before this change, the routing supervisor would evict a DO after 70–140 seconds of inactivity even if it had an open outbound connection — causing mid-stream evictions when, for example, streaming tokens from an LLM over a long-lived TCP socket.
Changes:
concepts/durable-object-lifecycle.mdx:::noteblock explaining the keepalive behavior, billing impact, 15-min cap, and that plainfetch()is excludedbest-practices/websockets.mdxplatform/pricing.mdxruntime-apis/tcp-sockets.mdxconnect()socket opened inside a DO pins it for up to 15 minuteschangelog/durable-objects/2026-06-19-...mdxKey accuracy notes verified against the merged implementation:
DEFAULT_HARD_LIMIT = 15 * kj::MINUTES) is exactfetch()is explicitly excluded (pass-through, no keepalive effect, even while streaming)fetch()upgraded to WebSocket viaUpgrade: websocketIS coveredDocumentation checklist