Back in September, we announced Durable Objects - a new paradigm for stateful serverless.
Since then, we’ve seen incredible demand and countless unlocked opportunities on our platform. We’ve watched large enterprises build applications from complex API features to real-time games in a matter of days from inception to launch. We’ve heard from developers that Durable Objects lets them spend time they used to waste configuring and deploying databases on building features for their apps. More than anything, we’ve heard that you want to start building with Durable Objects now.
As of today, Durable Objects beta access is available to anyone with a Cloudflare Workers® subscription - you can enable them now in the dashboard by navigating to “Workers” and then “Durable Objects”. You can also upgrade to the latest version of Wrangler to deploy Durable Objects!
Durable Objects are still in beta and are being made available to you for testing purposes. Storage is capped per-account at 10 GB of data, and there is no associated SLA for Object availability or durability.
What are Durable Objects?
Durable Objects provide two things: coordination across multiple Workers and strongly consistent edge storage.
Normally Cloudflare’s network executes a Worker wherever the client’s network request is terminated. This means there can be many instances of your Worker running at a given time all over the world, shown below.
In this example shown above, we’ve chosen our application’s user id as the Durable Object’s id. When a Worker needs access to a specific user’s data, they can contact the Object with that user’s id. That Object can then handle API calls and data access specific to that individual user.
Remember that Durable Objects scale incredibly well across multiple Object ids, but that each Object itself is backed by a single-thread. You should be careful to choose an id for your Objects that minimizes the number of requests processed by a single object. In our example above, if our user API grew to be too complicated, we might decide to have a separate id for each combination of a user id and an API endpoint to host in a single object.
While there’s no charge to use Durable Objects during the beta period, we want to share pricing so you can build your applications with confidence.
When you use Durable Objects, you are billed for the compute time your Object uses as well as the storage API operations your Object performs.
Durable Objects are significantly cheaper than comparable compute and storage offerings from the other major cloud providers.
As announced on the Workers Unbound blog, Durable Objects bills the standard Workers platform rates for long-running compute time.
|Durable Objects||AWS Lambda|
|Price per request||\$0.15 / MM||\$0.20-0.28 / MM|
|Compute ($ per MM GB-sec)||\$12.50||\$16.67 - \$22.92 (depending on geo)|
|Data Transfer||\$0.09 / GB||\$0.09/GB - \$0.15/GB (depending on geo)|
*Based on pricing disclosed on aws.amazon.com/lambda/pricing as of March 16, 2021. AWS’ published duration pricing is based on 1 GB-sec, which has been multiplied by one million on this table for readability. AWS price ranges reflect different regional pricing. All prices rounded to the nearest two decimal places. Data Transfer for AWS is based on Data Transfer OUT From Amazon EC2 to Internet above 1 GB / month, for up to 9.999 TB / month.
Durable Objects charges per storage operation for reads, writes and deletes and per GB-Month for data stored. Operations are metered in 4 KB increments - for example, an 8 KB read or write would be billed as two operations. When compared to AWS DynamoDB, Durable Objects charge less for every type of operation, and depending on the size of your operations, your savings could be significant. All price comparisons we’re showing below are based on single-region, strongly consistent DynamoDB storage. AWS charges extra for multi-region and transactionally consistent storage, which is already included for Durable Objects. If you use these features in DynamoDB, your savings will be even greater.
|Durable Objects||AWS DynamoDB|
|Price per MM read request||\$0.20 / MM / 4 KB||\$0.25 - \$0.375 / MM / 4 KB|
|Price per MM write request||\$1.00 / MM / 4 KB||\$1.25 - \$1.88 / MM / 1 KB|
|Price per MM delete request||\$1.00 / MM regardless of size||\$1.25 - \$1.88 / MM / 1 KB|
|Price per GB stored data||\$0.20 / GB||\$0.25 / GB|
*Based on pricing disclosed on aws.amazon.com/dynamodb/pricing/on-demand/ as of March 16, 2021. AWS price ranges reflect different regional pricing. All prices rounded to the nearest two decimal places.
We chose to meter our requests in 4 KB increments across the board to provide the lowest prices with the greatest flexibility. Deletes do not have a size limit.
We’ve seen that the vast majority of requests are actually smaller than 4 KB in size - Workers KV, our global, eventually consistent data store, has a median value size in the low single KB range.
Giving developers more for less
Not only are Durable Objects less expensive, they have a unique design that lets you do more than a traditional database layer.
Each Durable Object runs custom code that you write. After your Durable Object makes a request to a downstream API or to our storage API, the value can be cached in-memory for no-cost, low latency lookups.
Unlike major cloud-provider databases, Durable Objects are replicated to multiple distinct regions by default for high availability with no additional cost. With other cloud providers, this feature generally drives up costs - not to mention the increased complexity of self-managing multiple regions.
Durable Objects also provide strong consistency across operations by default. While many systems charge more for higher levels of consistency, running transactionally consistent storage from a Durable Object comes at no additional charge.
Since announcing Durable Objects, we’ve continued to add features to the platform, including:
- Smarter initial placement for user-named Objects, for lower latency access after initial creation.
- Jurisdictional Restrictions, allowing developers to restrict their Durable Objects to only run and store data in specific regions. This helps with compliance with data localization obligations.
- Wrangler support for uploading Durable Objects.
- Platform stability and increased capacity.
As we continue to add to the platform, we’re excited to see what you’re building as well. Come hang out in our Discord to ask questions and share what you’re building on Durable Objects!