Skip to content

Commit 038c78c

Browse files
authored
[DO] Clarifying how Durable Object is billed (#19752)
* Removing misleading sentence from DO pricing footnote. * Adding sentence. * Linking to event context glossary definition. * Implementing JH's feedback.
1 parent 3bf86ed commit 038c78c

File tree

1 file changed

+11
-33
lines changed

1 file changed

+11
-33
lines changed

src/content/partials/workers/durable_objects_pricing.mdx

+11-33
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,16 @@
22
{}
33
---
44

5-
import { Markdown } from "~/components";
5+
import { Markdown, GlossaryTooltip } from "~/components";
66

7-
[Durable Objects](/durable-objects/) are only available on the [Workers Paid plan](/workers/platform/pricing/#workers).
7+
[Durable Objects](/durable-objects/) are only available on the [Workers Paid plan](/workers/platform/pricing/#workers), and are billed while the Durable Object is active (including the <GlossaryTooltip term="event context"> event context</GlossaryTooltip>).
88

99
| | Paid plan |
1010
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
1111
| Requests | 1 million, + $0.15/million<br/> Includes HTTP requests, RPC sessions<sup>1</sup>, WebSocket messages<sup>2</sup>, and alarm invocations |
1212
| Duration<sup>3</sup> | 400,000 GB-s, + $12.50/million GB-s<sup>4,5</sup> |
1313

14-
<sup>1</sup> Each [RPC session](/workers/runtime-apis/rpc/lifecycle/) is billed
15-
as one request to your Durable Object. Every [RPC method
16-
call](/durable-objects/best-practices/create-durable-object-stubs-and-send-requests/)
17-
on a [Durable Objects stub](/durable-objects/) is its own RPC session and
18-
therefore a single billed request.
14+
<sup>1</sup> Each [RPC session](/workers/runtime-apis/rpc/lifecycle/) is billed as one request to your Durable Object. Every [RPC method call](/durable-objects/best-practices/create-durable-object-stubs-and-send-requests/) on a [Durable Objects stub](/durable-objects/) is its own RPC session and therefore a single billed request.
1915

2016
RPC method calls can return objects (stubs) extending [`RpcTarget`](/workers/runtime-apis/rpc/lifecycle/#lifetimes-memory-and-resource-management) and invoke calls on those stubs. Subsequent calls on the returned stub are part of the same RPC session and are not billed as separate requests. For example:
2117

@@ -26,31 +22,13 @@ await foo.baz(); // treated as part of the same RPC session created by calling b
2622
await durableObjectStub.cat(); // billed as a request
2723
```
2824

29-
<sup>2</sup> A request is needed to create a WebSocket connection. There is no
30-
charge for outgoing WebSocket messages, nor for incoming [WebSocket protocol
31-
pings](https://www.rfc-editor.org/rfc/rfc6455#section-5.5.2). For compute
32-
requests billing-only, a 20:1 ratio is applied to incoming WebSocket messages to
33-
factor in smaller messages for real-time communication. For example, 100
34-
WebSocket incoming messages would be charged as 5 requests for billing purposes.
35-
The 20:1 ratio does not affect Durable Object metrics and analytics, which
36-
reflect actual usage.
37-
38-
<sup>3</sup> Application level auto-response messages handled by
39-
[`state.setWebSocketAutoResponse()`](/durable-objects/best-practices/websockets/) will not
25+
<sup>2</sup> A request is needed to create a WebSocket connection. There is no charge for outgoing WebSocket messages, nor for incoming [WebSocket protocol
26+
pings](https://www.rfc-editor.org/rfc/rfc6455#section-5.5.2). For compute requests billing-only, a 20:1 ratio is applied to incoming WebSocket messages to factor in smaller messages for real-time communication. For example, 100 WebSocket incoming messages would be charged as 5 requests for billing purposes. The 20:1 ratio does not affect Durable Object metrics and analytics, which reflect actual usage.
27+
28+
<sup>3</sup> Application level auto-response messages handled by [`state.setWebSocketAutoResponse()`](/durable-objects/best-practices/websockets/) will not
4029
incur additional wall-clock time, and so they will not be charged.
4130

42-
<sup>4</sup> Duration is billed in wall-clock time as long as the Object is
43-
active, but is shared across all requests active on an Object at once. Once your
44-
Object finishes responding to all requests, it will stop incurring duration
45-
charges. Calling `accept()` on a WebSocket in an Object will incur duration
46-
charges for the entire time the WebSocket is connected. If you prefer, use
47-
[`state.acceptWebSocket()`](/durable-objects/best-practices/websockets/)
48-
instead, which will stop incurring duration charges once all event handlers
49-
finish running.
50-
51-
<sup>5</sup> Duration billing charges for the 128 MB of memory your Durable
52-
Object is allocated, regardless of actual usage. If your account creates many
53-
instances of a single Durable Object class, Durable Objects may run in the same
54-
isolate on the same physical machine and share the 128 MB of memory. These
55-
Durable Objects are still billed as if they are allocated a full 128 MB of
56-
memory.
31+
<sup>4</sup> Duration is billed in wall-clock time as long as the Object is active, but is shared across all requests active on an Object at once. Calling `accept()` on a WebSocket in an Object will incur duration charges for the entire time the WebSocket is connected. If you prefer, use the [WebSocket hibernation API](/durable-objects/best-practices/websockets/#websocket-hibernation-api) to avoid incurring duration charges once all event handlers finish running.
32+
33+
<sup>5</sup> Duration billing charges for the 128 MB of memory your Durable Object is allocated, regardless of actual usage. If your account creates many instances of a single Durable Object class, Durable Objects may run in the same isolate on the same physical machine and share the 128 MB of memory. These
34+
Durable Objects are still billed as if they are allocated a full 128 MB of memory.

0 commit comments

Comments
 (0)