More load is faster: Tuning Postgres read replicas
Postgres read replicas fed from archived WAL (rather than streaming replication) show a U-shaped lag curve: idle systems wait up to archive_timeout (60s) for a 16MB segment to fill, while very high write rates make archive upload fall behind. Moderate load gives about 3s lag by default. Setting archive_timeout=5s and wal_retrieve_retry_interval=500ms is a safe starting point. More aggressive options give diminishing returns because each poll costs about 0.8s of WAL-G calls, re-fetching and decompressing the previous segment, and adds cross-AZ network cost with synchronous HA. These options include sub-second pg_switch_wal() loops and a persistent WAL-G daemon client. Streaming replication still wins on lag but brings VACUUM, slot and failover hazards.
Related posts
- Introducing Read Replicas
Supabase mediumAdeptSupabase now supports Postgres read replicas in 12 regions, up to two per project, for offloading reads and analytics, serving data closer to users, and redundancy. Replication combines native streaming replication for low lag with file-based WAL shipping as a fallback, reusing their PITR pipeline (WAL-G archiving to S3) so replicas that fall behind past wal_keep_size can still catch up. Each replica gets its own Supavisor connection pool and PostgREST instance, with a round-robin load-balancing endpoint. Pricing covers replica compute and disk plus $0.09/GB WAL transfer, and automatic failover, geo-routing and Supavisor read/write splitting are planned.
- Don't add a read replica until you've read this
incident.io mediumAdeptincident.io moved nearly all Postgres read traffic to a read replica and had to preserve read-after-write consistency without hand-routing each query. Within a request, a Go context flag is tainted on any write or transaction so later reads go to the primary, a simple SELECT-prefix check classifies queries, and a circuit breaker falls back to the primary if the replica is unreachable. Across async boundaries, 0.1–0.5% of queue messages hit NotFound errors because workers ran faster than replication. The fix stamps each message and each mutating API actor (user or API key) with the primary's WAL LSN and checks pg_last_wal_replay_lsn() before reading from the replica. Lagging messages are nacked with exponential backoff, which doubles as backpressure, and replica lag is best monitored in bytes rather than time.
- PostgresBench: Measuring the impact of High Availability on Managed Postgres performance
ClickHouse mediumAdept
PostgresBench now measures the performance cost of high-availability configurations across managed Postgres services, comparing shared-nothing designs (ClickHouse Managed Postgres, RDS, Crunchy Bridge) that use streaming standbys with shared-storage forks (Aurora, Neon) that replicate WAL to a storage layer. On a 16 vCPU/64 GB instance with a 500 GB dataset, ClickHouse's NVMe-backed service dropped to 94% of single-node TPS with one async standby and 79% with two synchronous quorum standbys, with p99 latency rising 1.8x and 2.5x. RDS throughput was roughly flat, but its p99 rose to 1.7x with one sync standby and 6.3x (817 ms) with a two-standby quorum cluster. The vendor-run results claim 2-4x throughput advantages for ClickHouse over the other services at matched compute and comparable durability.
- 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.
- Rethinking read replicas for the lakebase architecture
Neon mediumAdept
Lakebase Postgres implements read replicas as additional read-only computes attached to the same disaggregated storage as the primary, rather than as physical clones with their own volumes. Each replica boots from a slim base backup from the pageserver, streams WAL from Paxos-replicated safekeepers instead of the primary, and reads pages via GetPage@LSN. As a result, creation takes seconds regardless of database size, N replicas still means one copy of the data, and replicas autoscale and scale to zero with no WAL backlog to replay on wake. The post contrasts this with RDS replica provisioning (snapshot, volume hydration, streaming replication catch-up) and lists per-workload uses such as analytics, investigations, read-only agent access and background jobs.