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

Summary

Neon's serverless driver optimizes PostgreSQL connections by redirecting the TCP wire protocol over WebSockets, which is particularly advantageous for serverless environments that lack state persistence. This approach reduces latency by minimizing network round-trips, from an initial nine down to four, through various strategies such as upgrading to TLS 1.3, eliminating unnecessary `SSLRequest` round-trips, and employing Postgres pipelining. Additionally, the driver replaces the SCRAM-SHA-256 authentication method with simple password authentication to further decrease latency and CPU usage, making it suitable for serverless platforms like Cloudflare Workers. The integration of TCP_NODELAY and direct WebSocket connections to the main Postgres proxy also contribute to the reduction of latency. Future improvements may involve leveraging WebSockets over QUIC in HTTP/3, potentially decreasing round-trips even further.