PostgreSQL pooler with sharding, load balancing and failover support
open sourceMITself-hostablefree
PgCat is a PostgreSQL connection pooler and proxy written in Rust on Tokio, made as a multi-threaded alternative to PgBouncer: it pools by transaction or session like PgBouncer, and adds load balancing of read queries across replicas and the primary, failover around broken replicas through health checks, and experimental sharding (by SQL syntax, query comments or automatic detection of the sharding key) and query mirroring. Statistics come from PgBouncer-style admin databases and a Prometheus endpoint, and the configuration reloads live. PostgresML built it and Instacart and OneSignal used it in production, but the repository has had no commits since February 2025 and its pull requests go unmerged.
Problems it solves
- a Postgres connection pooler that uses all CPU cores instead of a single thread
- send read-only queries to our Postgres replicas automatically without changing the app
- route around a broken Postgres replica without the app noticing
- shard a Postgres database by a key and route each query to the right shard from a proxy
- mirror production Postgres queries to a test server to try a new version under real load
- Prometheus metrics for our Postgres connection pool
- pool Postgres connections per transaction and balance them across a primary and replicas
Features
- transaction and session pooling
- multi-threaded runtime on Tokio
- load balancing of read queries between replicas and the primary
- failover around broken replicas, checked by regular health checks
- PgBouncer-compatible admin statistics through the pgbouncer and pgcat databases
- Prometheus statistics endpoint
- TLS between clients, pooler and servers
- MD5 client authentication; MD5 and SCRAM-SHA-256 to Postgres; auth passthrough with auth_query
- live configuration reloading
- experimental sharding by SQL syntax, query comments or automatic sharding-key detection
View 1 more
- experimental query mirroring to other databases
What people say
- Instacart's engineering blog on adopting PgCat as its Postgres proxy source
Alternatives
The same job
These do what PgCat does.
