Skip to content

Choose a data or storage product

Cloudflare Workers support a range of storage and database options for persisting different types of data across different use-cases, from key-value stores (like Workers KV) through to SQL databases (such as D1). This guide describes the use-cases suited to each storage option, as well as their performance and consistency properties.

Available storage and persistency products include:

  • Workers KV for key-value storage.
  • R2 for object storage, including use-cases where S3 compatible storage is required.
  • Durable Objects for transactional, globally coordinated storage.
  • D1 as a relational, SQL-based database.
  • Queues for job queueing, batching and inter-Service (Worker to Worker) communication.
  • Hyperdrive for connecting to and speeding up access to existing hosted and on-premises databases.
  • Analytics Engine for storing and querying (using SQL) time-series data and product metrics at scale.
  • Vectorize for vector search and storing embeddings from Workers AI.

Applications built on the Workers platform may combine one or more storage components as they grow, scale or as requirements demand.

Choose a storage product

Use-caseProductIdeal for
Key-value storageWorkers KVConfiguration data, service routing metadata, personalization (A/B testing)
Object storageR2User-facing web assets, images, machine learning and training datasets, analytics datasets, log and event data.
SQL databaseD1Relational data, including user profiles, product listings and orders, and/or customer data.
Time-series metricsAnalytics EngineWrite and query high-cardinality time-series data, usage metrics, and service-level telemetry using Workers and/or SQL.
Global co-ordinationDurable ObjectsBuilding collaborative applications; global co-ordination across clients; strongly consistent, transactional storage.
Vector search (database)VectorizeStoring embeddings from AI models for semantic search and classification tasks.
Task processing & batchingQueuesBackground job processing (emails, notifications, APIs) and log processing/batching.
Connect to an existing databaseHyperdriveConnecting to an existing database in a cloud or on-prem.

Performance and consistency

The following table highlights the performance and consistency characteristics of the primary storage offerings available to Cloudflare Workers:

FeatureWorkers KVR2Durable ObjectsD1
Maximum storage per accountUnlimited1Unlimited250 GiB250GiB 3
Storage grouping nameNamespaceBucketDurable ObjectDatabase
Maximum size per value25 MiB5 TiB per object128 KiB per value10 GiB per database 4
Consistency modelEventual: updates take up to 60s to be reflectedStrong (read-after-write)5Serializable (with transactions)Serializable (no replicas) / Causal (with replicas)
Supported APIsWorkers, HTTP/REST APIWorkers, S3 compatibleWorkersWorkers, HTTP/REST API

1 Free accounts are limited to 1 GiB of KV storage.

2 Free accounts are limited to 10 GB of R2 storage.

3 Free accounts are limited to 5 GiB of database storage.

4 Free accounts are limited to 500 MiB per database.

5 Refer to the R2 documentation for more details on R2’s consistency model.

Workers KV

Workers KV is an eventually consistent key-value data store that caches on the Cloudflare global network.

It is ideal for projects that require:

  • High volumes of reads and/or repeated reads to the same keys.
  • Per-object time-to-live (TTL).
  • Distributed configuration.

To get started with KV:

R2

R2 is S3-compatible blob storage that allows developers to store large amounts of unstructured data without egress fees associated with typical cloud storage services.

It is ideal for projects that require:

  • Storage for files which are infrequently accessed.
  • Large object storage (for example, gigabytes or more per object).
  • Strong consistency per object.
  • Asset storage for websites (refer to caching guide)

To get started with R2:

Durable Objects

Durable Objects provide low-latency coordination and consistent storage for the Workers platform through global uniqueness and a transactional storage API.

  • Global Uniqueness guarantees that there will be a single instance of a Durable Object class with a given ID running at once, across the world. Requests for a Durable Object ID are routed by the Workers runtime to the Cloudflare data center that owns the Durable Object.

  • The transactional storage API provides strongly consistent key-value storage to the Durable Object. Each Object can only read and modify keys associated with that Object. Execution of a Durable Object is single-threaded, but multiple request events may still be processed out-of-order from how they arrived at the Object.

It is ideal for projects that require:

  • Real-time collaboration (such as a chat application or a game server).
  • Consistent storage.
  • Data locality.

To get started with Durable Objects:

D1

D1 is Cloudflare’s native serverless database. With D1, you can create a database by importing data or defining your tables and writing your queries within a Worker or through the API.

D1 is ideal for:

  • Persistent, relational storage for user data, account data, and other structured datasets.
  • Use-cases that require querying across your data ad-hoc (using SQL).
  • Workloads with a high ratio of reads to writes (most web applications).

To get started with D1:

Queues

Cloudflare Queues allows developers to send and receive messages with guaranteed delivery. It integrates with Cloudflare Workers and offers at-least once delivery, message batching, and does not charge for egress bandwidth.

Queues is ideal for:

  • Offloading work from a request to schedule later.
  • Send data from Worker to Worker (inter-Service communication).
  • Buffering or batching data before writing to upstream systems, including third-party APIs or Cloudflare R2.

To get started with Queues:

Hyperdrive

Hyperdrive is a service that accelerates queries you make to existing databases, making it faster to access your data from across the globe, irrespective of your users’ location.

Hyperdrive allows you to:

  • Connect to an existing database from Workers without connection overhead.
  • Cache frequent queries across Cloudflare’s global network to reduce response times on highly trafficked content.
  • Reduce load on your origin database with connection pooling.

To get started with Hyperdrive:

Analytics Engine

Analytics Engine is Cloudflare’s time-series and metrics database that allows you to write unlimited-cardinality analytics at scale using a built-in API to write data points from Workers and query that data using SQL directly.

Analytics Engine allows you to:

  • Expose custom analytics to your own customers
  • Build usage-based billing systems
  • Understand the health of your service on a per-customer or per-user basis
  • Add instrumentation to frequently called code paths, without impacting performance or overwhelming external analytics systems with events

Cloudflare uses Analytics Engine internally to store and product per-product metrics for products like D1 and R2 at scale.

To get started with Analytics Engine:

Vectorize

Vectorize is a globally distributed vector database that enables you to build full-stack, AI-powered applications with Cloudflare Workers and Workers AI.

Vectorize allows you to:

  • Store embeddings from any vector embeddings model (Bring Your Own embeddings) for semantic search and classification tasks.
  • Add context to Large Language Model (LLM) queries by using vector search as part of a Retrieval Augmented Generation (RAG) workflow.
  • Filter on vector metadata to reduce the search space and return more relevant results.

To get started with Vectorize:

SQL in Durable Objects vs D1

Cloudflare Workers offers a SQLite-backed serverless database product - D1. How should you compare SQLite in Durable Objects and D1?

D1 is a managed database product.

D1 fits into a familiar architecture for developers, where application servers communicate with a database over the network. Application servers are typically Workers; however, D1 also supports external, non-Worker access via an HTTP API, which helps unlock third-party tooling support for D1.

D1 aims for a “batteries included” feature set, including the above HTTP API, database schema management, data import/export, and database query insights.

With D1, your application code and SQL database queries are not colocated which can impact application performance. If performance is a concern with D1, Workers has Smart Placement to dynamically run your Worker in the best location to reduce total Worker request latency, considering everything your Worker talks to, including D1.

SQLite in Durable Objects is a lower-level compute with storage building block for distributed systems.

By design, Durable Objects are accessed with Workers-only.

Durable Objects require a bit more effort, but in return, give you more flexibility and control. With Durable Objects, you must implement two pieces of code that run in different places: a front-end Worker which routes incoming requests from the Internet to a unique Durable Object, and the Durable Object itself, which runs on the same machine as the SQLite database. You get to choose what runs where, and it may be that your application benefits from running some application business logic right next to the database.

With SQLite in Durable Objects, you may also need to build some of your own database tooling that comes out-of-the-box with D1.

SQL query pricing and limits are intended to be identical between D1 (pricing, limits) and SQLite in Durable Objects (pricing, limits). During SQLite in Durable Objects beta, Storage per Durable Object is 1GB, which will be raised to mirror storage per D1 database (10GB) by general availability.