Sulat.com / Writing on AIWednesday, December 2, 2026
Enter →
Databases/2 December 2026

Datadog open sources PG Proxy, its PostgreSQL pooler

Datadog has open sourced PG Proxy, the Go PostgreSQL proxy it says handles 4 trillion queries a month. I built it, pooled 150 clients onto 10 connections and ran it against PgBouncer.

3D Datadog logo feeding many purple lines through a glass funnel into three PostgreSQL database cylinders
Illustration: Sulat, featuring the Datadog logo

At a glance

  • Datadog has open sourced PG Proxy, a Go PostgreSQL proxy and transaction pooler under Apache 2.0 that it says handles 4 trillion queries a month.
  • At Datadog it replaces a PgBouncer, HAProxy and Envoy stack, and adds read routing, central migration control and hooks for authentication and telemetry.
  • Datadog's JWT sign-in, load shedding and autoscaling stay internal, and the docs say configuration and Go APIs may change between releases.
  • In my test the proxy held 150 client sessions to 10 database connections, and 182 of 200 plain reads reached a replica.
  • In my smoke test on a shared four-core machine, PgBouncer 1.22.0 was faster than PG Proxy in every row.
  • The binary doesn't reload its configuration, and a SIGHUP kills it at once.

Datadog has open sourced PG Proxy, the PostgreSQL proxy its database platform team has run in production, under the Apache 2.0 licence. Datadog says it handles 4 trillion queries a month, more than 200 million authentications a day and more than 600,000 open client connections, in front of thousands of PostgreSQL hosts and hundreds of logical clusters. The table in its post counts that first figure as messages, not queries.

It’s written in Go. You can run the supplied binary as a transaction pooler, or embed the Go library and plug in your own authentication, routing and telemetry. Datadog calls the binary a drop-in replacement for PgBouncer, though it’s configured with a YAML or JSON file, not PgBouncer’s INI file.

Below: why Datadog built it, what’s in the release and what stays internal, my own run of it against a replica and PgBouncer, and the limits listed in its docs.

Datadog’s developer account announcing the release on X.

Why Datadog built it

Before PG Proxy, Datadog’s applications reached PostgreSQL by direct connection or through a mix of PgBouncer for pooling, HAProxy for load balancing and traffic shifting, and Envoy for discovery and health checks. Datadog says each piece had its own configuration, metrics and scaling behaviour, and nothing gave a consistent view of a request across all three. Authentication relied on shared static database credentials, so access couldn’t be tied to a single service.

Migrations were the other pain. Moving databases from cloud-managed PostgreSQL to Kubernetes meant coordinating DNS updates, proxy changes and application redeploys, then waiting on application teams to switch endpoints before cleanup could finish.

Before: PgBouncer, HAProxy, Envoy. After: one PG Proxy doing pooling, routing, tracing and auth hooks
One proxy now covers what three tools did at Datadog.

The project’s documentation says the PostgreSQL Platform team started building PG Proxy in 2023 after hitting limits in existing tools, PgBouncer among them. Datadog names two. When it began, PgBouncer didn’t support protocol-level named prepared statements in transaction pooling, so Datadog built that in; PgBouncer added it in version 1.21.0 in October 2023. And PgBouncer is single-threaded, so using more cores means running more processes and re-sizing pools to stay inside PostgreSQL’s connection limits. A single PG Proxy instance can use several cores.

What it does

FeatureWhat Datadog’s docs say
Transaction poolingMany client sessions share a smaller pool of backend connections. A session holds a connection only for the length of a transaction.
Prepared statementsNamed statements keep working when transactions land on different backend connections. Unnamed ones are parsed again per transaction unless a client opts into caching.
Read routingClient-facing database names map to clusters. With routing on, a transaction that opens with a plain SELECT, SHOW or BEGIN READ ONLY can go to a replica. About 90 per cent of eligible reads go to replicas, and a read falls back to the primary if no replica connection frees up within 50 ms.
Central migration controlApplications keep the same proxy address and database name while operators repoint the backend. Datadog’s own workflows stop new logins, drain active transactions and shift read and write routing.
Limits and shutdownClient sessions are capped separately from backend connections, and sessions drain at transaction boundaries on a planned stop.
Authentication and TLSTLS and SCRAM-SHA-256 for client connections, plus hooks to connect your own identity system.
TelemetryLogs, metrics and query traces over OpenTelemetry or native Datadog.
Traffic mirroringReplay live traffic against a separate database without slowing clients. Go library only.
From the repository README and its docs.

Tracing gets the most room in Datadog’s post. PG Proxy records spans for handling protocol messages, running and proxying queries, and returning results, and when a client supplies trace context those spans can join the application’s trace. An engineer can then tell time spent waiting on the database from time spent handing rows back to the application.

What’s in the release and what isn’t

What you get is a production-ready application and a Go library with extension points for destination selection, discovery, health checks, authentication and telemetry. Datadog’s JWT-based service sign-in and its client helpers aren’t part of it. The public library gives you the hooks to build your own policies.

Checklist: pooling, prepared statements, read routing, tracing and auth hooks are open; JWT, load shedding stay internal
The auth and load-shedding systems Datadog runs stay internal for now.

Datadog’s internal load-shedding and autoscaling systems are also separate from the release, and Datadog says it plans to add support for those capabilities in a future release. Its Database Monitoring integration may follow. The docs front page opens with a warning: this is early development, and configuration and Go APIs may change between releases.

I ran it

I built PG Proxy from source, put it in front of PostgreSQL 16 with a streaming replica, and ran PgBouncer 1.22.0 beside it for comparison. Everything ran on one four-core cloud machine. The pgbench figures are a smoke test, one run per cell, not a benchmark.

The build needs Go 1.26 and a C compiler, because the proxy uses CGO. It compiled in about a minute, and the README quick start worked as written: validate the config, start the proxy, connect with psql.

Terminal: pg-proxy validates config, logs proxy ready, and psql select 1 returns through the proxy from port 5432
The README quick start worked as written. Highlights are mine.

Pooling. I ramped up to 150 client sessions through the proxy with the pool capped at 10, each session running a small query every quarter of a second, and sampled PostgreSQL’s connection count throughout. The database never saw more than 10. With 100 busy pgbench clients, the count was 10 as well.

Client sessions climb to 150 while the backend count stops at 10. Rendered from the counts I sampled during the run.
150 app clients through PG Proxy with pool max 10 reach PostgreSQL over only 10 connections
Transaction pooling kept the database at 10 connections for 150 clients.

Prepared statements. pgbench in prepared mode ran 20 clients over the 10-connection pool for five seconds. It processed 182,705 transactions with no failures, and the prepared-mode runs against the default configuration in the table below also finished with no failed transactions.

Read routing. I added the replica to the cluster, turned on dynamic routing with a client startup option, and ran 200 show port statements. 182 reached the replica and 18 stayed on the primary, which fits the 90 per cent split in the docs.

Terminal: 200 SHOW port queries split 18 to primary 5432 and 182 to replica 5433 with dynamic routing on
About nine in ten plain reads reached the replica. Highlights are mine.

The classifier only sends a statement to a replica when it recognises it as a read. A select inet_server_port() went to the primary all 50 times, because the docs list only a short set of functions as read-only and a first function outside that list keeps the statement on the primary. A BEGIN READ ONLY transaction reached the replica in 35 of 40 tries, and a plain BEGIN never does.

Speed. I ran pgbench’s select-only script at scale 10, eight seconds per run, with 10 and 100 clients in simple, extended and prepared modes. The pool was 10 connections for both poolers. “Default” is the README configuration. “Tuned” adds the three settings Datadog’s benchmark page lists: reset_mode: dynamic, reply_buffer_pool: true and client_disconnect_timer: true.

Protocol, clientsDirect to PostgresPgBouncer 1.22.0PG Proxy defaultPG Proxy tuned
simple, 1068,22533,95719,95529,382
simple, 10056,38546,51120,08432,748
extended, 1067,74532,15416,66925,778
extended, 10052,27043,61518,36427,168
prepared, 1094,60835,36422,97233,879
prepared, 10079,43842,46923,72037,242
Transactions per second from pgbench -S, one eight-second run per cell, on a four-core machine that also ran pgbench and PostgreSQL.
Bar chart: Postgres direct 79k tps, PgBouncer 42k, PG Proxy tuned 37k, PG Proxy default 24k at 100 clients
On this machine PgBouncer led PG Proxy in every row.

PgBouncer was faster than PG Proxy in every row, and a direct connection beat both, which is normal for tiny queries over loopback. PG Proxy’s default configuration reached between 42 and 65 per cent of PgBouncer’s throughput. The tuned configuration reached between 62 and 96 per cent.

Datadog’s own benchmark page reports 165,000 to 196,000 transactions a second at 10 and 100 clients for a primary-key select on a 16-core EC2 instance with PG Proxy limited to four CPUs. My machine had four cores shared by the load generator, the pooler and the database, so the absolute numbers aren’t comparable. The page doesn’t compare PG Proxy with another pooler, and Datadog’s pitch isn’t speed against PgBouncer. It’s one component that replaces three and takes hooks for identity and telemetry.

The tuned settings come with a catch in Datadog’s own limitations page: with reset_mode: dynamic, a setting changed inside a function or trigger can leak to the next client of the same connection. I’d start on the default.

I didn’t test TLS and SCRAM, the Go library, traffic mirroring or the trace exporters. These are the commands, config and settings I ran:

Code
go build -o bin/pg-proxy ./cmd/pg-proxy
./bin/pg-proxy -config proxy.yaml -validate-config
./bin/pg-proxy -config proxy.yaml

pgbench -i -s 10 postgres
pgbench -h 127.0.0.1 -p 15432 -U postgres -S -M prepared -c 100 -j 2 -T 8 local_db
Code
# proxy.yaml (the README config, plus a streaming replica)
databases:
  - name: primary
    host: 127.0.0.1
    port: 5432
    dbname: postgres
    username: postgres
    password: postgres
    sslmode: disable
    max_conns: 10
  - name: replica
    host: 127.0.0.1
    port: 5433
    dbname: postgres
    username: postgres
    password: postgres
    sslmode: disable
    max_conns: 10
clusters:
  local:
    primary: primary
    replicas:
      - replica
logical_databases:
  local_db:
    cluster: local
proxy:
  listener_address: 127.0.0.1:15432

# tuned run: reset_mode: dynamic on the primary, and under proxy:
#   reply_buffer_pool: true
#   client_disconnect_timer: true

# pgbouncer.ini
pool_mode = transaction
default_pool_size = 10
max_prepared_statements = 100

Limits to read before you try it

Datadog’s own docs list where PG Proxy falls short. These matter most before a trial:

  • The binary reads its configuration once at startup and doesn’t reload it. Changes mean stopping it with SIGTERM, which drains sessions, and starting it again. A SIGHUP doesn’t reload, unlike PgBouncer. It kills the process at once.
  • Replica reads can be stale. A recent write doesn’t pin later transactions to the primary, so anything that must read its own write needs a destination that routes to the primary.
  • Routing is a first-statement heuristic. Named prepared statements aren’t classified, so clients such as pgx in its default mode send their reads to the main backend.
  • SQL-level PREPARE and EXECUTE, temporary tables, LISTEN and session-level advisory locks don’t carry across transactions.
  • After authentication there’s no limit on client message size, so a large enough message can exhaust the proxy’s memory.
  • SCRAM-SHA-256-PLUS channel binding isn’t implemented.
  • Traces can contain raw SQL and error messages. Turning off bind-parameter capture doesn’t remove literal values from the statement text, and there’s no general redaction.

How it compares

PoolerPoolingRouting
PG ProxyTransactionSQL classification, weighted read clusters, replica pool selection
PgBouncerSession, transaction, statementDatabase-to-host mappings; read and write routing is left to the client or surrounding infrastructure
Pgpool-IIConnections reused between sessionsRead and write routing with replica balancing
OdysseySession, transactionDatabase and user rules, primary and standby selection through target_session_attrs
PgDogSession, transactionRead and write splitting, replica balancing and sharding
From Datadog’s own pooler comparison, which covers documented capabilities, not speed.

My read: if you run one application against one PostgreSQL cluster behind PgBouncer, nothing in my numbers gives you a reason to move. PG Proxy is built for platform teams that want pooling, routing and their own identity and telemetry in a single Go process, and the clearest example is Datadog’s own: repointing a database without waiting for application teams to redeploy.

Sources: Datadog, Open sourcing PG Proxy, the repository, PG Proxy documentation, PgBouncer changelog.