Elephants in tunnels: how Hyperdrive connects to databases inside your VPC networks
Oct 25, 2024Andrew Repp, Emilio Assunção, Abhishek Chanda

Summary
This post details the technical implementation of integrating Hyperdrive with Cloudflare Tunnels to enable Workers to connect to private databases. It explains the custom Postgres message protocol handling, the use of Rust traits like AsyncRead and AsyncWrite for generic stream handling, and the development of a custom WebSocket stream implementation to bridge Hyperdrive's needs with the Tunnel's underlying WebSocket protocol. The post provides code examples for sending Postgres startup messages and illustrates the flexibility gained by abstracting transport layers.
More from the Internal Service Exposure & Management with Spectrum trail
- Route public traffic to private applications with Cloudflare
- Secure private networking for everyone: users, nodes, agents, Workers — introducing Cloudflare Mesh
- A QUICker SASE client: re-building Proxy Mode
- How Automatic Return Routing solves IP overlap
- How Workers VPC Services connects to your regional private networks from anywhere in the world