Skip to content

Introduction

PG Proxy sits between PostgreSQL clients and their databases. The Go library handles the PostgreSQL wire protocol, client sessions, routing, and transaction-level connection pooling.

Early development. Configuration and Go APIs may change between releases.

There are two ways to use PG Proxy: run the pg-proxy binary, or use the Go library to build your own proxy.

Run the pg-proxy binary: Configure it with a YAML or JSON file. Start with Local development, then follow Run in production to deploy it with TLS and password authentication.

Build your own application with the Go library: Supply your own configuration, authentication, routing, and telemetry integrations. See Go library configuration and Packages.

We’re Datadog’s PostgreSQL Platform team. We started building PG Proxy in 2023 after running into limitations with existing tools, including PgBouncer. We needed a pooler and proxy that we could adapt to how we run PostgreSQL at Datadog, so we built our own.

Since then, we’ve run it in production, fixed it, and learned what works. We think that work is useful outside Datadog too.

  • Features: Pooling, prepared statements, read routing, observability, and application integrations.
  • Limitations: Transaction-pooling constraints and current implementation limits.
  • Compare poolers: How PG Proxy compares with other connection poolers such as PgBouncer, Pgpool-II, Odyssey, and PgDog.
  • Benchmarks: PG Proxy throughput and latency under pgbench, and the settings used to measure them.
  • Telemetry configuration: Backend selection, options, defaults, and examples for OpenTelemetry and Datadog.
  • Metrics: Metric clients, session overrides, and selected measurements.
  • Tracing: Span operations, propagation, and recorded data.