A PostgreSQL proxy written in Rust that provides connection pooling, load balancing, and database sharding.
PgDog is a PostgreSQL proxy designed to scale database infrastructure through connection pooling, intelligent load balancing, and transparent sharding. It sits between applications and PostgreSQL servers, managing thousands of connections, distributing queries across replicas, and enabling horizontal scaling by splitting data across multiple database shards.
DevOps engineers, database administrators, and backend developers managing PostgreSQL deployments at scale, particularly those needing to improve connection efficiency, distribute read/write traffic, or implement sharding without major application changes.
Developers choose PgDog for its all-in-one approach to PostgreSQL scaling, combining the connection pooling of PgBouncer with advanced load balancing and native sharding capabilities, all built in Rust for high performance and reliability.
PostgreSQL connection pooler, load balancer and database sharder.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Built in Rust with Tokio, PgDog is optimized to handle thousands of connections on commodity hardware, leveraging modern async runtime for high-throughput workloads as highlighted in the performance documentation.
Uses PostgreSQL protocol-aware routing to automatically send writes to the primary and reads to replicas, supporting strategies like round robin, random, and least active connections, which maximizes database availability.
Supports partition-based and schema-based sharding with in-memory assembly for cross-shard queries, unique ID generation, and re-sharding capabilities via logical replication, enabling horizontal scaling without major app changes.
Offers RDS IAM authentication, allowing clients to use password-based auth while PgDog uses IAM tokens for backend connections, simplifying security in AWS environments.
Cross-shard queries have significant limitations: subqueries and CTEs are not supported, and aggregates, ORDER BY, and GROUP BY have only partial support, which can break complex queries in sharded setups.
Requires managing two separate TOML files (pgdog.toml and users.toml) and detailed setup for sharding, such as defining shard mappings and enabling rewrite features, increasing operational overhead compared to simpler proxies.
Licensed under AGPL v3, which mandates sharing modifications if offered as a public service, potentially deterring commercial cloud providers or teams wary of open-source compliance issues.
pgdog is an open-source alternative to the following products: