About this project

PgDog is an open-source PostgreSQL proxy written in Rust, designed to scale PostgreSQL deployments through connection pooling, load balancing across replicas, and horizontal sharding of databases. It operates as an application-layer (OSI Level 7) proxy that understands the PostgreSQL protocol, enabling intelligent query routing based on read/write intent, sharding keys, or schema context. Key features include: - Transaction and session pooling with advanced recovery mechanisms, including automatic rollback of abandoned transactions. - Load balancing across primary and replica nodes using round-robin, random, or least-active strategies, with real-time health checks and failover support. - Sharding via partition functions (HASH, LIST, RANGE) or schema-based routing, supporting cross-shard queries with in-memory result assembly. - Support for unique ID generation without sequences, shard key updates, multi-tuple inserts, and two-phase commit for atomic cross-shard writes. - Re-sharding capabilities using logical replication, allowing zero-downtime data redistribution. - Authentication flexibility: password-based, AWS RDS IAM, Azure Workload Identity, and HashiCorp Vault (dynamic/static roles). - Monitoring via OpenMetrics, OTEL, or PgBouncer-style admin database. Deployment options include Docker Compose, Helm charts for Kubernetes (including EKS), and Terraform modules for AWS ECS. Configuration uses TOML files (`pgdog.toml` for databases and settings, `users.toml` for credentials). The tool is optimized for performance on commodity hardware and includes built-in tools for schema and data synchronization during re-sharding. Documentation and community support are available via the official site and Discord. Enterprise edition features are documented separately.