Company
Date Published
Author
George MacKerron
Word count
2207
Language
English
Hacker News points
None

Summary

Neon has launched a beta version of its serverless PostgreSQL driver, @neondatabase/serverless, which allows users to connect to Neon databases from serverless computing platforms such as Cloudflare Workers and Vercel Edge Functions via WebSocket, overcoming the limitation of traditional PostgreSQL connections that rely on TCP. This new driver serves as a drop-in replacement for the popular node-postgres package, providing a seamless transition for existing codebases that depend on PostgreSQL connections. The driver operates by redirecting the PostgreSQL wire protocol through a WebSocket-to-TCP proxy, allowing for real, ordinary PostgreSQL connections. The proxy, written in Go, is open-source and facilitates traffic relay without security requirements, while the driver library itself is based on node-postgres with necessary shims for compatibility with V8 isolates. To ensure secure connections, a small C program using WolfSSL has been compiled to WebAssembly to handle TLS encryption, although the developers are considering a move to a pure JavaScript-based TLS solution. The driver is optimized for performance by utilizing modern authentication methods like SCRAM-SHA-256 and aims to minimize latency by deploying proxies in multiple regions and employing TLS 1.3 for fewer handshake messages. Neon invites developers to try out the serverless driver and proxy, both of which are open-source, to make any PostgreSQL database accessible over WebSockets.