---
title: "Quicker serverless Postgres connections"
description: "Neon cut the network round-trips needed to get a first query result from its WebSocket-based serverless Postgres driver from nine to four."
url: "https://swe.quest/articles/quicker-serverless-postgres-connections-7a37a1071edd4362"
canonical: "https://neon.com/blog/quicker-serverless-postgres"
source: "Neon"
published: "2023-03-28"
difficulty: "medium"
kind: "Case study"
reading_minutes: 8
tags: ["postgres","networking","serverless","performance","cryptography"]
---

# Quicker serverless Postgres connections

A post on [Neon](https://swe.quest/sources/neon.md), published 2023-03-28, 8 min read, Case study. Original: [https://neon.com/blog/quicker-serverless-postgres](https://neon.com/blog/quicker-serverless-postgres)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Networking](https://swe.quest/tags/networking.md) (Infrastructure)
- [Serverless](https://swe.quest/tags/serverless.md) (Backend & APIs)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Cryptography](https://swe.quest/tags/cryptography.md) (Security)

## Prerequisites

- Postgres wire protocol basics ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- TLS handshake ([easy posts on Cryptography](https://swe.quest/tags/cryptography.md?difficulty=easy))
- TCP and WebSockets ([easy posts on Networking](https://swe.quest/tags/networking.md?difficulty=easy))

## Keywords

Neon serverless driver, WebSockets, TLS 1.3, SCRAM-SHA-256, Nagle's algorithm, node-postgres, Cloudflare Workers, QUIC

## Related posts

- [Edge-compatible Serverless Driver for Postgres](https://swe.quest/articles/edge-compatible-serverless-driver-for-postgres-9b0d09c6c7a067d0.md): Neon · 2022-12-08 · Medium · 9 min read · PostgreSQL, Serverless, Networking, Cryptography, WebAssembly
  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.
- [HTTP vs. WebSockets: Which protocol for your Postgres queries at the Edge](https://swe.quest/articles/http-vs-websockets-which-protocol-for-your-postgres-queries-at-the-edge-25a9317092665f21.md): Neon · 2023-07-11 · Medium · 5 min read · PostgreSQL, Serverless, Performance engineering, CDN & edge, Networking
  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.
- [@neondatabase/serverless hits 1.0.0](https://swe.quest/articles/neondatabase-serverless-hits-1-0-0-d5430675bc92b751.md): Neon · 2025-03-25 · Medium · 5 min read · PostgreSQL, Serverless, TypeScript, Application security, JavaScript
  Neon's JavaScript/TypeScript serverless driver, which carries Postgres queries over HTTP and WebSockets for environments without raw TCP such as V8 isolates and browsers, reaches 1.0.0 after a refactor that adds auto-generated types via api-extractor and CI tests across Node, Bun, Deno, browsers, Cloudflare Workers, Vercel and the Prisma/Drizzle adapters.
- [Sub-10ms Postgres queries for Vercel Edge Functions](https://swe.quest/articles/sub-10ms-postgres-queries-for-vercel-edge-functions-6bc9caef6fab65ca.md): Neon · 2023-07-10 · Medium · 3 min read · PostgreSQL, Serverless, CDN & edge, Performance engineering, TypeScript
  Neon's serverless Postgres driver now supports SQL-over-HTTP via fetch, and Neon's proxy adds opt-in experimental connection caching (\`fetchConnectionCache\`).
- [Using Hyperdrive with Neon and Cloudflare Workers: FAQ](https://swe.quest/articles/using-hyperdrive-with-neon-and-cloudflare-workers-faq-3467430ed9174f03.md): Neon · 2024-12-26 · Medium · 5 min read · PostgreSQL, Serverless, CDN & edge, Caching, Performance engineering
  Cloudflare Hyperdrive is a globally distributed connection pooler and read-query cache for Workers.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
