Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Neon 5 min read How-to mediumAdept

Using Hyperdrive with Neon and Cloudflare Workers: FAQ

Cloudflare Hyperdrive is a globally distributed connection pooler and read-query cache for Workers. Because Workers keep warm connections at the nearest edge node, the ~6 round trips of TCP setup, TLS handshake, Postgres auth and query collapse to one. Neon measured roughly 9x faster global SELECT queries with Hyperdrive. Neon's recommendation is to connect Hyperdrive with standard TCP drivers like node-postgres or Postgres.js, and to skip both Neon's PgBouncer pooler and the Neon serverless driver, which uses WebSockets or HTTP and is redundant or incompatible here.

Assumes: Postgres connectionsCloudflare Workers basicsconnection pooling

Related posts

  • Quicker serverless Postgres connections

    Neon mediumAdept

    Neon cut the network round-trips needed to get a first query result from its WebSocket-based serverless Postgres driver from nine to four. It moved to TLS 1.3, ran Postgres unencrypted inside a secure wss: WebSocket (or pipelined SSLRequest with the TLS Client Hello), and replaced CPU-heavy SCRAM-SHA-256 with plain password auth over TLS, since Neon only issues long random passwords. It also pipelined the startup, password and query messages into a single send. Pipelining at first added up to 50ms of delay over short distances because of Nagle's algorithm, fixed by setting TCP_NODELAY in the proxy. QUIC-based WebSockets or WebTransport might cut the count further.

  • Edge-compatible Serverless Driver for Postgres

    Neon mediumAdept

    Neon's @neondatabase/serverless driver lets V8-isolate platforms like Cloudflare Workers, which lack TCP, speak the real Postgres wire protocol by tunnelling it over a WebSocket to an open-source Go proxy that relays to TCP. The driver is node-postgres with shims for Node APIs, and it does end-to-end TLS 1.3 via WolfSSL compiled to WebAssembly with Asyncify, offloading crypto to SubtleCrypto. Because SCRAM-SHA-256's 4,096 hash rounds exceed Workers' 10–50ms CPU limits, it falls back to cleartext auth over mandatory TLS. The post also covers latency tradeoffs from the extra proxy hop, round-trip reductions, and how to self-host the proxy for any Postgres.

  • Sub-10ms Postgres queries for Vercel Edge Functions

    Neon mediumAdept

    Neon's serverless Postgres driver now supports SQL-over-HTTP via fetch, and Neon's proxy adds opt-in experimental connection caching (`fetchConnectionCache`). Together they cut query latency from Vercel Serverless and Edge Functions by about 40%, bringing same-region one-shot queries to single-digit milliseconds. Use the `neon` HTTP function for a single query per invocation and `Pool` when a function runs multiple queries. Drizzle-ORM also supports the driver for type-safe queries.

  • Build and Deploy a Global Serverless Nuxt SSR App with Cloudflare Hyperdrive and Postgres

    Neon mediumAdept

    A Nuxt SSR app on Cloudflare Pages can query Neon Postgres through Hyperdrive by routing Drizzle's pg-proxy driver to a separate Hono-based Cloudflare Worker that holds the Hyperdrive binding and runs queries with node-postgres. The detour through a Worker exists because Pages Functions don't fully support node-postgres yet, which breaks local Nuxt builds. The walkthrough covers the nitro cloudflare-pages preset, creating the Hyperdrive config from a pooled Neon connection string, wrangler.toml with node_compat, the Worker's /query endpoint, and the Drizzle proxy driver. Hyperdrive's default cache serves responses for 60 seconds with a 15-second stale-while-revalidate window. The example endpoints are unauthenticated and must be locked down before production use.

  • HTTP vs. WebSockets: Which protocol for your Postgres queries at the Edge

    Neon mediumAdept

    Neon's serverless Postgres driver now supports SQL-over-HTTP alongside WebSockets, and benchmarks from Vercel Edge and Serverless functions (iad1 to us-east-1) show each wins in different cases. WebSockets, cut from nine to four round-trips, give ~5ms latency for queries after the first but ~37ms for a single-shot query including connection setup. HTTP is faster for one-shot queries but lacks sessions, interactive transactions, NOTIFY and COPY. An experimental proxy-side connection cache (fetchConnectionCache) saves almost 10ms by finding the compute node faster. Choose HTTP for single queries and WebSockets for multiple queries per invocation, and note the runtime matters as much as the protocol.

The quest for software engineering knowledge.

Look:
Layout: