PgGate

Go PostgreSQL Prometheus

PgGate

Overview

Built a protocol-aware PostgreSQL proxy from scratch — parsing the PostgreSQL Frontend/Backend Protocol v3 without external wire-protocol libraries. Comparable in design intent to PgBouncer and PgCat; built solo in Go.


Key Features

  • Read/Write Splitting — Routes queries to primary or replicas based on statement type
  • Connection Pooling — Efficient pool management reducing connection overhead at scale
  • Session Pinning — Correct handling of transactions and SET commands requiring sticky routing
  • Sub-millisecond Routing Latency — Protocol-level routing with minimal overhead
  • 10,000+ Concurrent Connections — Designed for high-concurrency production workloads
  • Prometheus Metrics — Full observability with exported connection and routing metrics
  • SIGHUP Hot Reload — Config changes applied without dropping connections

Tech Stack

  • Language: Go
  • Protocol: PostgreSQL wire protocol v3 (parsed from scratch)
  • Observability: Prometheus
  • Transport: TCP