BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Cloudflare Hyperdrive: Access PostgreSQL Databases Globally

Cloudflare Hyperdrive: Access PostgreSQL Databases Globally

This item in japanese

During the recent "Birthday Week 2023", Cloudflare announced the open beta of Hyperdrive, a new service that uses Cloudflare global network to speed up queries to existing databases. The service currently supports PostgreSQL-compatible databases, with support for MySQL expected soon.

To make data access faster from anywhere in the world, regardless of end-users locations, Hyperdrive caches the most popular database queries. This can enhance full-stack application performance and reduce the load and cost on the database. Furthermore, Hyperdrive enables database connection pooling for Workers, reducing latency caused by repeatedly establishing new database connections.

Matt Silverlock, director of product at Cloudflare, and Alex Robinson, principal engineer at Cloudflare, write:

In a modern distributed cloud environment like Workers, where compute is globally distributed (so it’s close to users) and functions are short-lived (so you’re billed no more than is needed), connecting to traditional databases has been both slow and unscalable. Slow because it takes upwards of seven round-trips (TCP handshake; TLS negotiation; then auth) to establish the connection, and unscalable because databases like PostgreSQL have a high resource cost per connection.

The new service supports a wide range of the most popular database providers, including those hosted on AWS, Google Cloud, Neon, and Timescale, as well as Postgres-compatible databases like CockroachDB. Support for MySQL is expected by the end of the year, both for the community edition and providers like PlanetScale.

With Hyperdrive, developers keep using their existing drivers, query builder, and ORM (Object-Relational Mapper) libraries. Silverlock and Robinson explain:

To achieve this, we worked with the maintainers of popular open-source drivers — including node-postgres and Postgres.js — to help their libraries support Worker’s new TCP socket API, which is going through the standardization process, and we expect to see land in Node.js, Deno and Bun as well.

To demonstrate Hyperdrive’s performance and functionalities, Cloudflare provides a demo application that queries against the same database both directly and with Hyperdrive.

According to Cloudflare, Hyperdrive’s connection pooling will always be free for both database protocols supported today and new database protocols. During the open beta, query caching and analytics are free and pricing details will be announced closer to general availability, expected early in 2024.

User NetworkIsSpreading on Reddit comments:

I'll still use D1 because SQLite is great for small/medium read-heavy sites but this opens up a ton of workflows now that you can plug and play with your existing database. Doesn't this render Prisma's Data Proxy useless?

Hyperdrive was not the only database-related announcement during the "Birthday Week 2023": Cloudflare unveiled the open beta of D1, their native serverless database, and of Vectorize, a new managed vector database for AI-powered applications.

About the Author

Rate this Article

Adoption
Style

BT