PgDog is a PostgreSQL connection pooler, load balancer, and database sharder written in Rust.
PgDog addresses the challenge of scaling PostgreSQL by managing connection overhead and distributing queries across multiple database instances. It operates as a proxy that sits between applications and PostgreSQL servers, implementing transaction and session pooling to allow thousands of client connections to share a smaller pool of actual database connections. The tool can parse and handle SET statements and startup options to maintain correct session state when connections are shared between clients with different parameters, and it includes advanced recovery mechanisms such as automatic abandoned transaction rollbacks and connection re-synchronization.
The tool suits applications that need to reduce connection overhead on PostgreSQL or distribute load across multiple database instances. It works well in Kubernetes environments through a Helm chart and on AWS through either EKS with Helm or ECS via a Terraform module. For those evaluating alternatives, PgDog differs from PgBouncer in its ability to handle SET statements and startup options correctly during connection sharing, and it offers more advanced connection recovery options to avoid connection churn during application crashes. The load balancer operates at the application layer and supports round robin, random, and least active connections strategies across multiple replicas and primaries. All features are configurable and can be enabled or disabled independently, with configuration managed through two files for hosts and sharding settings, and separate credentials management.
The project maintains active development with regular updates to both open source and enterprise editions, each with separate changelogs. The tool is production-ready and deployable across multiple infrastructure platforms with documented quick-start paths for Docker, Kubernetes, and AWS environments.