Cloudflare Docs
Durable Objects
Edit this page on GitHub
Set theme to dark (⇧+D)

Pricing

​​ Billing metrics

Durable Objects are only available on the Workers Paid plan.

Paid plan
Requests11 million, + $0.15/million
Duration2400,000 GB-s, + $12.50/million GB-s3,4

1 Requests include all incoming HTTP requests, WebSocket messages, and alarm invocations. There is no charge for outgoing WebSocket messages, nor for incoming WebSocket protocol pings.

2 Application level auto-response messages handled by state.setWebSocketAutoResponse() will not incur additional wall-clock time, and so they will not be charged.

3 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. Once your Object finishes responding to all requests, it will stop incurring duration charges. Calling accept() on a WebSocket in an Object will incur duration charges for the entire time the WebSocket is connected. If you prefer, use state.acceptWebSocket() instead, which will stop incurring duration charges once all event handlers finish running.

4 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 Durable Objects are still billed as if they are allocated a full 128 MB of memory.

​​ Durable Objects billing examples

These examples exclude the costs for the Workers calling the Durable Objects. When modelling the costs of a Durable Object, note that:

  • Inactive objects receiving no requests do not incur any duration charges.
  • The WebSocket Hibernation API can dramatically reduce duration-related charges for Durable Objects communicating with clients over the WebSocket protocol, especially if messages are only transmitted occassionally at sparse intervals.

​​ Example 1

This example represents a simple Durable Object used as a co-ordination service invoked via HTTP.

  • A single Durable Object was called by a Worker 1.5 million times
  • It is active for 1,000,000 seconds in the month

In this scenario, the estimated monthly cost would be calculated as:

Requests:

  • (1.5 million requests - included 1 million requests) x $0.15 / 1,000,000 = $0.075

Compute Duration:

  • 1,000,000 seconds * 128 MB / 1 GB = 128,000 GB-s
  • (128,000 GB-s - included 400,000 GB-s) x $12.50 / 1,000,000 = $0.00

Estimated total: ~$0.075 (requests) + $0.00 (compute duration) + minimum $5/mo usage = $5.08 per month

​​ Example 2

This example represents a moderately trafficked Durable Objects based application using WebSockets to broadcast game, chat or real-time user state across connected clients:

  • 100 Durable Objects have 50 WebSocket connections established to each of them.
  • Clients send approximately one message a minute for eight active hours a day, every day of the month.

In this scenario, the estimated monthly cost would be calculated as:

Requests:

  • 50 requests to each of the 100 Durable Objects to establish the WebSockets (5,000 connections created each day, total 150,000 connection requests).
  • 50 messages per minute * 100 Durable Objects * 60 minutes * 8 hours * 30 days = 72,000,000 requests + 150,000 connection requests.
  • (~72 million requests - included 1 million requests) x $0.15 / 1,000,000 = $10.65.

Compute Duration:

  • 100 Durable Objects * 60 seconds * 60 minutes * 8 hours * 30 days = 86,400,000 seconds.
  • 86,400,000 seconds * 128 MB / 1 GB = 11,059,200 GB-s.
  • (11,059,200 GB-s - included 400,000 GB-s) x $12.50 / 1,000,000 = $133.24.

Estimated total: $10.65 (requests) + $133.24 (compute duration) + minimum $5/mo usage = $148.89 per month.

​​ Example 3

This example represents a horizontally scaled Durable Objects based application using WebSockets to communicate user-specific state to a single client connected to each Durable Object.

  • 100 Durable Objects each have a single WebSocket connection established to each of them.
  • Clients sent one message every second of the month so that the Durable Objects were active for the entire month.

In this scenario, the estimated monthly cost would be calculated as:

Requests:

  • 100 requests to establish the WebSockets.
  • 1 message per second * 100 connections * 60 seconds * 60 minutes * 24 hours * 30 days = 259,200,000 requests
  • (259.2 million requests - included 1 million requests) x $0.15 / 1,000,000 = $38.73

Compute Duration:

  • 100 Durable Objects * 60 seconds * 60 minutes * 24 hours * 30 days = 259,200,000 seconds
  • 259,200,000 seconds * 128 MB / 1 GB = 33,177,600 GB-s
  • (33,177,600 GB-s - included 400,000 GB-s) x $12.50 / 1,000,000 = $409.72

Estimated total: $38.73 (requests) + $409.72 (compute duration) = $453.45 per month

​​ Example 4

This example represents a moderately trafficked Durable Objects based application using WebSocket Hibernation to broadcast game, chat or real-time user state across connected clients:

  • 100 Durable Objects each have 100 Hibernatable WebSocket connections established to each of them.
  • Clients send one message per minute, and it takes 10ms to process a single message in the webSocketMessage() handler. Since each Durable Object handles 100 WebSockets, cumulatively each Durable Object will be actively executing JS for 1 second each minute (100 WebSockets * 10ms).

In this scenario, the estimated monthly cost would be calculated as:

Requests:

  • 100 requests to each of the 100 Durable Objects to establish the WebSockets (10,000 initial connections).
  • 100 messages per minute1 * 100 Durable Objects * 60 minutes * 24 hours * 30 days = 432,000,000 requests
  • (432 million requests - included 1 million requests) x $0.15 / 1,000,000 = $64.65

Compute Duration:

  • 100 Durable Objects * 1 second2 * 60 minutes * 24 hours * 30 days = 4,320,000 seconds
  • 4,320,000 seconds * 128 MB / 1 GB = 552,960 GB-s
  • (552,960 GB-s - included 400,000 GB-s) x $12.50 / 1,000,000 = $1.91

Estimated total: $64.65 (requests) + $1.91 (compute duration) + Minimum $5/mo usage = $71.56 per month

1 100 messages per minute comes from the fact that 100 clients connect to each DO, and each sends 1 message per minute.

2 The example uses 1 second because each Durable Object is active for 1 second per minute. This can also be thought of as 432 million requests that each take 10 ms to execute (4,320,000 seconds).

​​ Transactional Storage API billing

The Durable Objects Transactional Storage API is only accessible from within Durable Objects.

Durable Objects do not have to use the Transactional Storage API, but if your code does call methods on state.storage, it will incur the following additional charges:

Paid plan
Read request units1,21 million, + $0.20/million
Write request units31 million, + $1.00/million
Delete requests41 million, + $1.00/million
Stored data51 GB, + $0.20/ GB-month

1 A request unit is defined as 4 KB of data read or written. A request that writes or reads more than 4 KB will consume multiple units, for example, a 9 KB write will consume 3 write request units.

2 List operations are billed by read request units, based on the amount of data examined. For example, a list request that returns a combined 80 KB of keys and values will be billed 20 read request units. A list request that does not return anything is billed for 1 read request unit.

3 Each alarm write is billed as a single write request unit.

4 Delete requests are unmetered. For example, deleting a 100 KB value will be charged one delete request.

5 Durable Objects will be billed for stored data until the data is removed. Once the data is removed, the object will be cleaned up automatically by the system.

Requests that hit the Durable Objects in-memory cache or that use the multi-key versions of get()/put()/delete() methods are billed the same as if they were a normal, individual request for each key.