Skip to content

PATTERN Cited by 1 source

Connection pooler as separate deployment

Statement

Run the connection pooler as its own Kubernetes Deployment, fronted by a dedicated Service, spread across availability zones for availability — rather than colocating it with the database or embedding it in the application.

This is the default shape Zalando's Postgres Operator chose for PgBouncer in release 1.5: "Postgres Operator creates a single connection pooler deployment and exposes it via new service."

When to use it

  • Standard cloud-native Postgres deployments where the pooler is one more autonomous workload managed by an operator.
  • Stateless-pooler workloads — PgBouncer processes are cheap to replace, kill, restart. Horizontal scaling is the primary knob.
  • Mixed AZ environments where the pooler must stay available if one AZ fails.

Why it works

  • Independent scaling: pooler replicas scale on their own schedule, driven by CPU pressure or connection demand, not tied to Postgres lifecycle.
  • Independent lifecycle: rolling pooler upgrades don't touch the database; rolling database upgrades leave the pooler's connections in place.
  • Stateless + lightweight: pooler pods have no persistent state; restart is cheap (<100 MB memory, transaction-state- ephemeral).
  • Fits Kubernetes primitives cleanly: Deployment + Service is the idiomatic shape.

Trade-off: latency variability

The deployment-spread model introduces latency variability from three sources:

  1. AZ-spread adds inter-AZ network latency — a pooler pod in AZ-a talking to a Postgres primary in AZ-b pays the cross-AZ RTT on every query.
  2. iptables kube-proxy distributes non-uniformly — some pods get more load and slow under pressure.
  3. Kubernetes scheduler may land pods on shared hyperthreads, triggering softirq contention.

For workloads that can't tolerate this variability, the patterns/big-pooler-affinity-plus-small-pooler-ha pattern is the operator-documented escape hatch.

Instances

Seen in

Last updated · 476 distilled / 1,218 read