PgCat is a PostgreSQL pooler and proxy similar to PgBouncer, but with added support for sharding, load balancing, and automatic failover. It aims to improve the scalability and availability of PostgreSQL databases by distributing connections across multiple servers. PgCat utilizes the Tokio asynchronous runtime to efficiently handle a large number of concurrent connections.
PgCat distinguishes itself with experimental sharding capabilities based on SQL syntax and automatic shard detection. It offers a robust set of features like multi-threaded runtime, automatic failover, and integration with Prometheus for detailed monitoring. The project is actively developed, with a clear focus on production-readiness and substantial performance demonstrated in live deployments.
- Transaction Pooling: Same functionality as PgBouncer, with enhancements for handling bad clients and abandoned transactions.
- Load Balancing: Automatically distributes read queries between primary and replica servers.
- Failover: Automatically reroutes queries around unresponsive servers based on health checks.
- Sharding: Dynamically routes queries to specific database shards using SQL syntax or comment parsing.
- Prometheus Statistics: Exposes metrics for monitoring performance and resource utilization.
- SSL/TLS: Supports secure client and server connections with TLS encryption.
- Live Configuration Reloading: Allows dynamic updates to most configuration settings without downtime.
PgCat is currently stable and used in production environments, handling hundreds of thousands of queries per second. The project demonstrates active development based on recent commits and community contributions. While some features are experimental, the core functionality is well-tested and reliable, backed by various integration and unit tests.
PgCat benefits developers and operations teams by simplifying the management and scaling of PostgreSQL databases. It addresses challenges of high query loads and desired high availability by providing automatic sharding, intelligent load balancing, and automatic failover. The project is particularly valuable for applications requiring horizontal scalability and resilience.
