PG Proxy is Datadog’s open-source PostgreSQL proxy, written in Go, designed to consolidate connection pooling and traffic management that previously required a mix of direct connections, PgBouncer, HAProxy, and Envoy. That fragmented setup meant separate configurations and limited visibility, and made database migrations dependent on coordinated DNS changes and application redeployments. PG Proxy gives applications a stable access point while platform teams centrally manage backend destinations. It supports self-managed and cloud-hosted PostgreSQL and can be run as a supplied application or integrated as a Go library.
The proxy uses transaction pooling to let many client connections share fewer PostgreSQL connections, and supports named prepared statements with pooling. It can route eligible read-only transactions to replicas, falling back to the primary if a replica cannot provide a connection promptly; applications can disable this routing when they need immediate visibility of their own writes. Central routing also enables staged migrations and draining transactions before cutovers. Authentication hooks and tracing integrations connect database access to service identity and help follow requests, though Datadog’s JWT system, load shedding, autoscaling, and database-monitoring integration are not part of the open-source release. Datadog reports using PG Proxy across thousands of hosts and hundreds of clusters, handling four trillion messages monthly, more than 200 million authentications daily, and over 600,000 open client connections.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.