Datadog shares the database proxy it runs at huge scale
Datadog has open sourced PG Proxy, a connection manager for PostgreSQL databases written in Go, and published the post on 1 December. The company says its own copy handles 4 trillion messages a month. Some internal parts, including its login integration and overload protection, were left out of the public release.
PG Proxy is a PostgreSQL proxy that combines connection pooling, traffic management and hooks for authentication, configuration and telemetry. It works with self-managed and cloud-hosted PostgreSQL.
Datadog says it replaced a mix of PgBouncer, HAProxy and Envoy, each with its own settings and metrics. PgBouncer is single-threaded, so scaling meant running more copies. In Datadog's production use, as the company reports, PG Proxy handles more than 1,000 messages a second per core, over 200 million logins a day and more than 600,000 open client connections.
Several things are not in the open release: Datadog's JWT login integration, its client helpers, and its load-shedding and autoscaling systems. Overload protection is planned for later. Reading from replicas is opt-in per connection, because replica lag can hide recent writes. Query values can still show up in SQL text and error messages in traces.
If you run PgBouncer today, this is a candidate to test, not a switch to make this week.
New to this? The key idea
Many apps open far more database connections than a database can handle. A proxy sits in the middle and shares a small number of real connections, like a restaurant host seating many guests at a few tables. It can also route traffic and record what happens.
Use it at work
Use it for: platform and database engineers who run PgBouncer, HAProxy or Envoy in front of PostgreSQL and want one component with built-in tracing.
Try it: follow the quick start in github.com/DataDog/pg-proxy to run it as a drop-in PgBouncer replacement, or embed it as a Go library with your own login and telemetry hooks. Start with a representative workload in staging and compare connection and routing behaviour.
Before you roll it out: licence not stated in the announcement, so check the repository. Leave dynamic read routing off if your app needs to read its own writes immediately. Moving the main destination can interrupt transactions that have not drained. Bind-parameter capture in traces is off by default, but values can still leak through SQL text. Datadog's numbers are its own.
Summaries are written by AI from the linked source. Always check the original.