PgDog
PgDog is a PostgreSQL query router, pooler, proxy and load balancer written in Rust. Spiritual successor to pgcat, PgDog comes with a lot of similar features, better performance, and introduces new features like plugins and cross-shard queries.
PostgreSQL deployments of any size can be proxied by PgDog, ranging from a single database to hundreds of primaries and replicas in a sharded configuration.
Installation
PgDog is easily compiled from source. Before proceeding, make sure you have the latest version of the Rust compiler, available from rust-lang.org.
Checkout the code
PgDog source code can be downloaded from GitHub:
Compile PgDog
PgDog should be compiled in release mode to make sure you get all performance benefits. You can do this with Cargo:
Configuration
PgDog is configured via two files:
pgdog.toml
which contains general pooler settings and PostgreSQL server informationusers.toml
which contains passwords for users allowed to connect to the pooler
The passwords are stored in a separate file to simplify deployments in environments where secrets can be safely encrypted, like Kubernetes or AWS EC2.
Both files can to be placed in the current working directory (CWD) for PgDog to detect them. Alternatively,
you can pass the --config
and --secrets
arguments with their locations when starting PgDog.
Example pgdog.toml
Most PgDog configuration options have sensible defaults. This allows a basic primary-only configuration to be pretty short:
Example users.toml
This configuration file contains a mapping between databases, users and passwords. Users not specified in this file won't be able to connect to PgDog:
Launch the pooler
Starting the pooler can be done by running the binary in target/release
folder or with Cargo: