Datadog Open-Sources PG Proxy to Unify PostgreSQL Pooling and Routing
Datadog open-sourced PG Proxy, a multi-core Go PostgreSQL pooler and router handling 600,000+ connections and 4 trillion monthly messages internally.
By Dillip Chowdary • Dec 06, 2026 • Source: InfoQ

At a glance
- Product
- Datadog PG Proxy (Go PostgreSQL proxy and pooler)
- Published
- December 6, 2026
- Availability
- Open-source code and docs on GitHub
- Production scale
- 600,000+ connections, ~4 trillion messages/month
- Core throughput
- >1,000 messages/sec per core, >200M auths/day
- Excluded features
- Internal load-shedding, JWT auth, DB Monitoring hooks
In this post
Datadog has open-sourced PG Proxy, a PostgreSQL proxy and transaction-level connection pooler written in Go, according to InfoQ's report. The release gives platform teams a single access layer to manage connection pooling, traffic routing, and backend destinations rather than operating separate infrastructure tools. Inside Datadog, PG Proxy already sits in front of thousands of PostgreSQL hosts and hundreds of logical clusters.
This article examines how Datadog consolidated its database access stack, how PG Proxy handles transaction pooling and prepared statements, and what throughput the Go service achieves in production. It also covers dynamic read-write routing, migration workflows, extension hooks for authentication and tracing, and which internal features remain excluded from the open-source code. Platform engineers, database reliability teams, and Go backend developers evaluating PgBouncer alternatives will find the technical scope and current protocol limits detailed below.
01Consolidating PgBouncer, HAProxy, and Envoy
Before building PG Proxy, Datadog applications connected to PostgreSQL through a fragmented mix of direct connections and three separate intermediaries. Teams relied on PgBouncer for connection pooling, HAProxy for load balancing and traffic shifting, and Envoy for service discovery and health checks. Maintaining those distinct layers forced engineers to manage separate configurations, metrics pipelines, and scaling knobs across every environment.
That split architecture also complicated routine database migrations and cluster topology changes. Whenever a backend database moved, operators had to coordinate updates across DNS records, proxy settings, and application endpoints at the same time. Any mismatch between those moving parts risked connection drops or misrouted queries during cutovers.
PG Proxy replaces that multi-tool chain with a unified access layer that decouples client endpoints from backend host locations. Applications continue connecting to the same proxy endpoint and database name even as operators swap or rebalance underlying PostgreSQL clusters. Centralizing pooling and routing removes the need to synchronize external load balancers and discovery proxies during infrastructure changes.
02Transaction pooling and named prepared statements
PG Proxy operates as a transaction-level connection pooler, allowing many long-lived client sessions to share a smaller pool of backend PostgreSQL connections. Instead of pinning a server connection to one client for its entire session, the proxy reassigns backend connections between transactions. This approach keeps backend connection counts manageable under heavy application concurrency.
Supporting named prepared statements in transaction mode has historically been a pain point for PostgreSQL poolers. When Datadog began developing PG Proxy, PgBouncer did not yet support protocol-level named prepared statements alongside transaction pooling. PG Proxy solves this by tracking each client's prepared statements in memory and automatically preparing them on whichever backend connection handles the next transaction.
Note: Newer client protocol features still have gaps in the open-source release. Asked on X whether PG Proxy handles libpq 17 direct TLS with ALPN postgresql and prepared statements in transaction mode out of the box, Datadog Developers replied: "We don’t handle that specific feature today, but you can open up an issue on the GitHub repo if it’s something you'd like to see, and we can take a look."
03Multi-core Go scaling and production throughput
Advertisement
Tech Pulse Daily
Get tomorrow's pulse first
Join engineers who read Tech Pulse before stand-up. Free, weekday mornings.
Unlike PgBouncer, which runs on a single-threaded process model, each PG Proxy instance in Go can utilize multiple CPU cores concurrently. That multi-core architecture lets platform teams scale proxy capacity vertically on modern hosts without running and balancing multiple single-process pooler instances per machine.
Datadog reports substantial production volume across its internal fleet running PG Proxy. The company measures more than 1,000 messages per second per CPU core and over 200 million authentications per day across its clusters. At peak scale, the proxy layer handles more than 600,000 open client connections and routes approximately 4 trillion messages per month.
Not every production capability from Datadog's internal deployment is included in the public repository. Specifically, the internal load-shedding mechanisms and Database Monitoring hooks that Datadog runs internally are absent from the open-source release today. Teams adopting the public codebase will need to supply their own overload protection or external monitoring integrations.
04Dynamic read-write routing and cluster migrations
When dynamic routing is enabled, PG Proxy inspects transaction boundaries to separate read traffic from write traffic automatically. Read-only transactions can be directed to replica servers, while write transactions remain pinned to the primary PostgreSQL instance. Clients opt into this routing behavior on a per-connection basis by passing a startup option.
The router includes safeguards to prevent subtle consistency bugs when splitting traffic across primaries and replicas. It prioritizes the primary server for locking reads and for most function calls that could carry side effects or require primary state. This conservative routing keeps application semantics intact without requiring manual query annotations.
Operators can also update backend destinations centrally through PG Proxy during live cluster migrations. Rather than flipping all traffic at once, teams can shift a portion of read queries to a new cluster before executing the final write cutover. Because clients keep using the same proxy endpoint, migrations happen transparently to application code.
05Authentication hooks and OpenTelemetry tracing extensions
Both authentication and observability are structured as extension points in the open-source PG Proxy library. Internally at Datadog, services authenticate to the proxy using JSON Web Tokens carried inside the PostgreSQL password field. That internal JWT validation system is not part of the public release, so the open-source build exposes hooks for custom identity checks.
For observability, PG Proxy emits distributed tracing spans covering PostgreSQL protocol handling and query proxying. When client applications supply supported trace context, the proxy can link its database spans directly into end-to-end application traces. Teams can export this telemetry either through native Datadog instrumentation or via OpenTelemetry.
Datadog has published the PG Proxy source code and documentation on GitHub for organizations looking to embed or run the Go proxy. By leaving authentication and telemetry pluggable, the project allows external engineering teams to integrate PG Proxy with their existing identity providers and tracing backends without adopting Datadog's proprietary stack.
Frequently asked questions
What tools does Datadog PG Proxy replace?
PG Proxy consolidates connection pooling, load balancing, and service discovery into one Go layer. Before building it, Datadog relied on a mix of direct connections, PgBouncer, HAProxy, and Envoy.
Does PG Proxy support named prepared statements in transaction pooling mode?
Yes. PG Proxy tracks each client's named prepared statements and prepares them on whichever backend connection is assigned for a transaction.
Does PG Proxy support libpq 17 direct TLS with ALPN postgresql?
Not today. Datadog Developers stated on X that the feature is not currently supported, and invited users to open an issue on GitHub if they want it added.
Which internal Datadog features are missing from the open-source PG Proxy release?
Datadog's internal load-shedding, Database Monitoring hooks, and password-field JWT authentication system are excluded from the public build. The open-source library provides extension hooks for custom authentication and OpenTelemetry or Datadog tracing.
Sources
Author
Dillip Chowdary
Writes Tech Bytes coverage of AI, engineering, and the tools that actually ship. Editor of Tech Pulse Daily.
Related on Tech Bytes
Advertisement