Connect Hyperdrive to a PlanetScale Postgres database.
PlanetScale Postgres & MySQL
Create PlanetScale Postgres or MySQL databases with globally distributed Workers applications.
Cloudflare partners with PlanetScale ↗ to provide PlanetScale-hosted Postgres and MySQL (Vitess) databases to Workers. Hyperdrive connects Workers to PlanetScale databases with built-in database connection pooling and query caching for faster performance.
Get the best of both products, build for Workers global distribution and optimize for regional data access. Get started by creating a PlanetScale database in the Cloudflare dashboard.
Go to Create a PlanetScale databaseWith Workers, build your application to deploy anywhere across Cloudflare’s global network spanning 330+ cities. You can deploy with a single step, and users in new locations can reach your application without deploying regional infrastructure.
Workers compute runs close to your users for low latency. PlanetScale Postgres provides regional databases for your application's control plane or any centralized data that doesn't fit Cloudflare's edge distribution model. Use it for records such as customers, billing, account settings, or other relational data.
Hyperdrive provides the connection glue between Workers and PlanetScale. It pools database connections and uses Cloudflare's Cache for eligible read queries to make your application fast even when your database is centralized.
-
Run near the user. When a user sends a request, Cloudflare routes it to a nearby location. Your Worker runs in that location, so request handling starts close to the user.
-
Check for cached reads locally. On the same Cloudflare server handling the Worker request, Hyperdrive sets up your database connection in single digit milliseconds (p90 4ms) so that your database client/driver can send queries immediately. Hyperdrive's connection setup performs TCP ↗ connection startup, TLS ↗ encryption, and client authentication all on the same local machine, removing any network roundtrips and latency to your database. Once the database connection is ready if the Worker sends a cacheable read query and the result is cached, Hyperdrive returns it without leaving that location.
-
Forward when needed with caching in-between. If no local cached result exists, or if the query cannot be cached, Hyperdrive sends the query across Cloudflare's network to a location close to your PlanetScale database. Hyperdrive checks another cache in that location before it reaches the database; this cache is populated by multiple requests to your database to improve your cache hit ratios similar to tiered caching .
-
Query PlanetScale only when necessary. If neither cache has the result, Hyperdrive sends the query to PlanetScale using an already available pool of database connections. Writes and other uncacheable queries go to PlanetScale so the database remains the source of truth. Multiple layers of caching reduce overall load on your database.
Choose PlanetScale Postgres or MySQL, and keep using familiar database drivers, object-relational mapping (ORM) libraries, and SQL tooling.
Run production databases on PlanetScale infrastructure with commitment to performance and reliability that power trusted customer workloads ↗.
Use development branches ↗ to test database changes, query insights ↗ to understand query performance, and the Model Context Protocol (MCP) server ↗ to give agents access to database insights data, all without needing a database administrator (DBA).
When you create a PlanetScale database from the Cloudflare dashboard, you are billed via your Cloudflare account — you will see a line item on your Cloudflare invoice for your PlanetScale usage. The pricing for PlanetScale is the same when you create and use databases via Cloudflare as it is when you buy directly from PlanetScale. For more pricing details, refer to PlanetScale's pricing ↗. You can introspect per-database billing usage via PlanetScale's dashboard ↗.
Connect Hyperdrive to a PlanetScale MySQL database.
Create a Hyperdrive configuration and query a database from Workers.
Learn how Hyperdrive pools connections and caches queries.