PgDog is a Rust proxy that pools PostgreSQL connections, balances read traffic across replicas, and routes sharded queries using the native SQL parser. Clients connect to PgDog as they would to a single database endpoint.
Overview
PgDog scales PostgreSQL behind one proxy process that understands the wire protocol. Transaction and session pooling let many application clients share a small set of server connections, with handling for SET statements and startup options when connections are shared.
As a layer-seven load balancer, it distributes transactions across primaries and replicas using round robin, random, or least-active strategies, with health checks that remove failed hosts from rotation. Read and write splitting sends mutating statements to the primary and SELECT queries to replicas when configured.
Sharding maps tables or schemas to shards using partition-style hash, list, or range rules, or schema-based placement. Cross-shard queries merge results in memory, with growing support for aggregates and ordered results; two-phase commit can coordinate multi-shard writes.
Authentication integrates password hashing, AWS RDS IAM, Azure Workload Identity, and HashiCorp Vault dynamic or static credentials. Deployment options documented include Docker Compose, a Helm chart, and binary configuration via pgdog.toml and users.toml.
Key features
- Transaction and session connection pooling
- Replica load balancing with health checks
- Automatic read and write splitting
- Multi-shard query routing and merging
- Vault and cloud IAM backend auth
- Failover-aware write redirection
- Helm and Docker deployment
Use cases
- Pool thousands of app connections to few Postgres backends
- Expose one endpoint for primary and replicas
- Horizontally shard large Postgres datasets
- Front RDS or Patroni clusters with failover handling