HeadlinesBriefing favicon HeadlinesBriefing.com

PgDog Scales Postgres with No App Changes - Production-Ready

Hacker News •
×

Lev and Justin have launched PgDog, a Rust-based proxy that scales PostgreSQL through connection pooling, load balancing, and database sharding without requiring application code changes. The tool is now in production with direct-to-shard queries working reliably, while cross-shard queries are being actively developed. PgDog handles aggregate functions like count(), min(), max(), avg(), stddev(), and variance() transparently by calculating results in-transit.

Key features include atomic cross-shard writes using two-phase commit, omnisharded tables for replicated data, and automatic support for multi-tuple inserts from ORMs like Prisma and Sequelize. The proxy also offers a cross-shard unique sequence generator that produces up to 4 million numbers per second without requiring migration to UUIDv7. Built-in resharding can move gigabytes of tables per second by parallelizing logical replication streams across replicas.

PgDog includes a smart load balancer that monitors replicas and redirects write traffic during failover, working seamlessly with managed services like RDS, Azure Pg, and GCP Cloud SQL. The tool automatically handles connection storms through abandoned transaction rollbacks and query re-synchronization, preserving database connections during application crashes. PgDog is open source and welcomes contributions.