Worker calls Hyperdrive locally
Your Worker talks to Hyperdrive on the same edge node — sub-millisecond roundtrip. No TCP, no TLS, no auth from the Worker's perspective.
Database Connection Pooling at the Edge
Stop drowning your database in TCP handshakes. Let Cloudflare's edge handle the connections, so your serverless functions run at wire speed.
Every time a stateless Worker (or Lambda, or Edge Function) talks to a traditional database, it opens a brand new TCP + TLS connection. At scale, this creates three pain points:
| Pain Point | What Happens | Cost |
|---|---|---|
| Connection Exhaustion | Postgres maxes out at ~100–500 connections. 10,000 concurrent Workers = database meltdown. | Downtime, rejected queries |
| Latency Tax | TCP handshake + TLS negotiation + auth every single request. | 50–200ms added per query |
| Cold Start Penalty | Each Worker invocation re-establishes everything from scratch, even for identical queries. | Slow UX, wasted compute |
Hyperdrive maintains a pool of persistent, authenticated connections to your database from every Cloudflare PoP (300+ cities). When your Worker needs data:
Your Worker talks to Hyperdrive on the same edge node — sub-millisecond roundtrip. No TCP, no TLS, no auth from the Worker's perspective.
Hyperdrive picks an existing connection from its pool to your database. The database sees a stable, long-lived client — not 10,000 new connections.
The query runs over the warm connection. Result flows back through Hyperdrive → Worker. Connection goes back to the pool.
For repeated read queries, Hyperdrive caches results at the edge. Same SELECT comes in again? Served from cache — database never touched.
| Scenario | What Happens | Latency |
|---|---|---|
| Cache Hit | Result served from edge cache | ~1–5ms |
| Cache Miss | Query forwarded to database via pooled connection | Query execution time only |
| Write Query | Always forwarded to database; cache unaffected for writes | Query execution time |
Note: Cache is TTL-based. You configure expiration globally or per-query. No manual invalidation API — tune TTL to your data freshness tolerance.
Hyperdrive is configured in your Wrangler config, not in application code:
Then in your Worker:
Your origin database credentials are stored securely in Cloudflare's config — never in code.
| Database | Status |
|---|---|
| PostgreSQL | ✅ Primary target — full support |
| MySQL | ✅ Supported |
| CockroachDB, YugabyteDB | ✅ Wire-compatible with Postgres |
Hyperdrive is bundled inside the Workers plan — no separate Hyperdrive invoice. If you're already on Workers Paid, it's effectively free unlimited.
"Hyperdrive is PgBouncer at the edge, managed by Cloudflare, with an optional read cache bolted on. It makes your serverless functions talk to your monolithic database without drowning it in connections."