Getting Started

Introduction

Overview of HTTP PostgreSQL Gateway — connecting serverless and edge workloads to PostgreSQL safely over HTTP.

Introduction to HTTP PostgreSQL Gateway

HTTP PostgreSQL Gateway is a persistent bridge between HTTP-only runtimes and PostgreSQL. It allows serverless and edge clients to make stateless HTTPS requests while the gateway maintains reusable PostgreSQL connection pools on a private network where TCP or Unix-socket database access is available.


The Serverless Database Dilemma

Serverless platforms like Cloudflare Workers, Vercel Functions, AWS Lambda, Deno Deploy, and Bun present unique operational challenges when connecting directly to relational databases:

  • No Direct Socket Support: Many edge runtimes (such as V8 isolates) cannot open raw TCP sockets to PostgreSQL.
  • Connection Storms: Each serverless instance opens its own TCP connection. Spikes in concurrent traffic can quickly exhaust PostgreSQL's max_connections limit.
  • Expensive TLS Handshakes: Re-establishing TLS connections and authenticating with PostgreSQL on every cold start introduces significant latency.
  • Distributed Database Secrets: Storing master database credentials inside numerous client-side or distributed deployment configs increases exposure risk.

HTTP PostgreSQL Gateway solves these problems by providing a high-performance HTTP front-end that lives close to PostgreSQL, manages the backend connection lifecycle, and enforces strict authorization.


Core Capabilities

Native fetch() Support
Query PostgreSQL using standard HTTPS JSON requests without native binary drivers or socket shims.
Persistent Connection Pooling
Maintains prewarmed, verified PostgreSQL sessions with automatic DISCARD ALL rollbacks and resets.
Scoped Database Roles
Maps API keys to dynamically provisioned, least-privilege PostgreSQL roles with granular CRUD permissions (c, r, u, d).
Idempotent Atomic Batches
Submit multi-statement transactions with Idempotency-Key headers to guarantee exactly-once commit behavior.
Asynchronous Query Queue
Queue queries that outlast typical serverless execution windows (up to 5 minutes) and poll for results.
Built-in Observability
Worker-thread SQLite analytics, query counting, and automatic SQL literal sanitization for failed queries.

Architecture at a Glance

Rendering diagram...

The service separates administrative database access from client query access. API-key scopes are translated directly into PostgreSQL roles, ensuring that PostgreSQL remains the ultimate authorization boundary for SQL execution.


Gateway vs. Other Solutions

FeatureDirect DriverPgBouncer / PgpoolHTTP PostgreSQL Gateway
ProtocolNative TCPNative TCPHTTPS / JSON (fetch())
Edge Isolation FriendlyNo (requires TCP)No (requires TCP)Yes (Native HTTP)
Credential DistributionDB passwords in functionsDB passwords in functionsScoped Bearer API Keys
Authorization BoundaryClient SQL stringClient SQL stringPostgreSQL Role per Scope
Async ExecutionNoneNoneYes (Persistent background queue)
Idempotent TransactionsClient managedClient managedYes (Idempotency-Key tracking)
Failed SQL SanitizationApplication logsRaw logsYes (Auto-redacted analytics)

Next Steps

Copyright © 2026