Skip to main content
24.02.2026

PgDog: Scale PostgreSQL Without Changing Your App

head-image

Scaling PostgreSQL has traditionally meant choosing between connection poolers like PgBouncer, manual sharding implementations, or expensive managed solutions. PgDog combines all three capabilities into a single, high-performance proxy written in Rust.

What Is PgDog?

PgDog is an open-source PostgreSQL proxy that handles connection pooling, load balancing, and database sharding. Unlike PgBouncer, it parses SQL using the native PostgreSQL parser, enabling smart query routing and automatic primary/replica detection. It manages thousands of connections on commodity hardware while maintaining low latency.

Key Features

  • Transaction pooling with automatic SET statement handling and session state management
  • Load balancing across replicas with round-robin, random, or least-connections strategies
  • Health checks that remove unhealthy databases from rotation automatically
  • Single endpoint routing that sends writes to primary and reads to replicas
  • Native sharding using PostgreSQL partition functions (HASH, LIST, RANGE)
  • Automatic failover detection when replicas are promoted

Installation

Deploy with Helm on Kubernetes:

helm repo add pgdogdev https://helm.pgdog.dev
helm install pgdog pgdogdev/pgdog

Or try locally with Docker Compose:

docker-compose up
PGPASSWORD=postgres psql -h 127.0.0.1 -p 6432 -U postgres

Basic Configuration

Configure a simple pool in pgdog.toml:

[general]
port = 6432
default_pool_size = 10

[[databases]]
name = "prod"
host = "10.0.0.1"
role = "primary"

[[databases]]
name = "prod"
host = "10.0.0.2"
role = "replica"

PgDog automatically routes writes to primary and distributes reads across replicas.

Operational Tips

Enable automatic failover monitoring with lsn_check_delay = 0 and set database roles to auto. PgDog monitors replication state and redirects traffic when a replica is promoted. For sharded deployments, define sharding keys in your configuration to enable direct-to-shard routing for optimal performance.

Conclusion

PgDog simplifies PostgreSQL scaling by combining pooling, balancing, and sharding in one tool. For SRE teams managing growing databases, it eliminates the complexity of stitching multiple solutions together.

Akmatori helps teams monitor and automate database operations at scale. For high-performance hosting, check out Gcore.

Automate incident response and prevent on-call burnout with AI-driven agents!