What is WAL backpressure, and why does ClickHouse Managed Postgres need it?
ClickHouse Managed Postgres prevents WAL-full PANICs, which happen when writes outpace archiving to object storage, by throttling client write bandwidth with the cgroup v2 I/O controller. A systemd timer counts pending WAL segments every 15 seconds and applies tiered write caps of 80%, 50% and 20% of provisioned disk throughput at 100, 500 and 1,000 segments. Processes are sorted by process title into an immune cgroup (archiver, checkpointer, WAL writer, logger) and a throttled one (client backends), and reads are never capped. In a pgbench test with a rate-limited archive_command, the backlog peaked at 3,433 segments (53 GiB), the disk never passed 33% full, and the backlog drained in under four minutes once storage recovered. One caveat: WAL-heavy workloads see throughput cut much more than WAL production, which fell only about 10%.
Related posts
- What else runs on your Postgres server, and how do we stop it from taking the database down?
ClickHouse mediumAdept
Supporting processes on a managed Postgres VM (PgBouncer, WAL-G, Prometheus, exporters, log collector, watchdogs) share memory, CPU and disk with the database, so a leak or CPU burst in any of them can take it down. ClickHouse Managed Postgres confines them to a cgroup v2 slice using systemd MemoryHigh/MemoryMax, with per-service GOMEMLIMIT values summing below memory.high. Go's GC reacts first, the kernel throttles at memory.high, and any OOM at memory.max is scoped away from Postgres, which runs in a separate cgroup. Backups get reduced CPU weight, WAL-G buffers and log-collector memory are bounded, exported metrics are allowlisted, and a disk-full watchdog kills application sessions while exempting replication and monitoring roles.
- How we scale PgBouncer in ClickHouse Managed Postgres
ClickHouse mediumAdept
Because PgBouncer is single-threaded, ClickHouse Managed Postgres runs a fleet of PgBouncer processes sized to the core count, all binding one port via so_reuseport so the kernel load-balances connections behind a single endpoint. Peering between processes forwards cancel requests that land on the wrong process, and max_client_conn and max_db_connections are divided across the fleet so Postgres is never oversubscribed. On a 16-vCPU c7i.4xlarge with pgbench select-only load, a single process peaked near 87k TPS and degraded to 77k at 256 clients while pinned at one core. A 16-process fleet reached about 336k TPS (roughly 4x) using about 8 cores. At very low concurrency the single process is marginally faster, so the fleet pays off only once the pooler becomes the bottleneck.
- What I learned from a month with WalShadow on ClickHouse Managed Postgres
ClickHouse mediumAdept
WalShadow, which decodes physical Postgres WAL outside the database and writes blocks directly to ClickHouse, held median replication latency near 0.4 s from 1 to 200,000 rows/s on a 16 vCPU source. ClickPipes, which uses logical replication, tracked its Sync interval (about 31 s median at the 60 s default) and saturated around 50,000–55,000 rows/s regardless of interval or pipe compute size. Data matched exactly across source and both destinations, and schema changes, restarts, resizes and destination stops needed no manual action. Caveats include temporary cross-table inconsistency from parallel per-table writes, fixed `_commit_ts`/`_lsn` on initially loaded rows that can break TTLs, materialized views seeing raw row versions, and commit-ordered delays behind large transactions.
- Everyone gets faster writes: We turned off FPW's in Neon
Neon hardMaster
Neon disabled Postgres full-page writes fleet-wide because its stateless compute streams WAL to a Paxos safekeeper quorum and has no local disk pages that can tear. To keep delta chains bounded without FPW images, the pageserver now generates page images itself once a page accumulates more deltas than a threshold, rather than relying on the checkpoint cycle. HammerDB TPROC-C throughput rose up to 4.5x on 32 vCPU, and WAL per transaction fell from 58KB to under 4KB (94%). In production, p99 read latency dropped 30-50%, and the change was rolled out without restarts via the XLOG_FPW_CHANGE WAL record.
- Building an enterprise Postgres service in ClickHouse Cloud
ClickHouse easyNovice
ClickHouse Cloud's managed Postgres runs on NVMe with up to two cross-AZ synchronous standbys using quorum commit (acknowledged when one standby confirms) and automatic failover. Standbys are deliberately kept off read traffic so WAL replay lag and VACUUM interference don't delay failover; separate read replicas handle read scaling. Other features include failover-safe logical replication slots that keep ClickPipes/PeerDB CDC into ClickHouse running across failovers without full resyncs, WAL-G daemon-based continuous archiving for 7-day PITR and forks, and per-cluster dedicated VPCs with TLS, AES-256 at rest and Private Link. Planned work includes GCP support, near-sub-second CDC v2, Query Performance Insights and Terraform support.