ClusterPostgreSQL-Series — PostgreSQL Multi-Master & Active-Active Architectures¶
Author: Jean-Marie Renouard (jmrenouard) | Supported by: LightPath | License: MIT | Version française : README.fr.md
This repository provides a comparative PostgreSQL study, a 40-criterion matrix, and 13 Docker Compose labs (jmrenouard/multi-db-docker-env v2.6.4). The harness runs 18 functional/limit probes (L1-L8, T11-T18) plus PG 18.6 AIO, uuidv7(), conflict, and YT T_REVERT checks. We collected 628 raw benchmark rows (310 baseline PG_SCALE=2 / 301 deduplicated + 318 V5 tuned PG_SCALE=20 pgbench/sysbench/tc netem) across 18 live PostgreSQL topologies (cockroach-rc included, 16 solutions / 19 architecture sheets). The repo also stores 22 GitHub popularity rows (19 repos + 3 closed/managed), 13 log10 charts, and dashboard/index.html.
Executive Summary¶
PostgreSQL is built on a single-writer WAL engine (LSN, XID, ProcArray, local heap pages). Turning PostgreSQL into an "active-active multi-master" system forces an unavoidable trade-off along the PACELC spectrum:
- Asynchronous Logical & Trigger Meshes (
PA/EL): Nodes commit locally under15 mseven with50 msWAN RTT (647–824 TPS). Contended workloads lose updates (-71Kto-531Kdrift) or stall on23505. CRDT Delta-Apply avoids this (spock.delta_applyreached1,837.64 TPSwith0drift). - Distributed Consensus Raft/Paxos (
PC/EC): Raft guaranteesRPO = 0and0drift. Cross-node RTT cuts throughput (-76%to-97%under25 msWAN delay). Clients needSQLSTATE 40001retries (sysbenchfailed685of1,587attempts on CockroachDB). - Single-Primary HA Control (
#15 Patroni + etcd): Remains the lowest-TCO, zero-conflict optimal choice for 80%+ of OLTP workloads.
Empirical Benchmark & Limits Headline Matrix (PG_SCALE = 2)¶
Executed sequentially inside isolated Docker bridge networks on a 20-vCPU / 16.4 GiB host (results/benchmark_summary.csv, results/functional_limits_matrix.csv):
| Topology (Solution #) | Suite A Single RW (TPS) | Suite B2 Overlap RW (TPS) | Suite D Hot Conflict TPS (Drift) |
Suite E sysbench TPS (Failed) |
Suite F WAN 25ms TPS |
Verified SQLSTATE Limits |
|---|---|---|---|---|---|---|
pg17-standalone (#15) |
866.82 |
879.01 |
3,128.63 (0) |
1,129.51 (112) |
N/A | 23505 (Single writer) |
pg17-async-streaming (#15) |
610.15 |
584.80 |
2,081.26 (0) |
962.84 (107) |
599.61 (-2%) |
25006 RO; WAL seq 66\|true |
pg17-sync-streaming (#15) |
409.48 |
465.22 |
1,370.10 (0) |
819.36 (118) |
57.00 (-86%) |
23505; 25006; 25.8 @ 50ms |
pg17-logical (#16 Uni) |
532.38 |
355.57 |
2,386.93 (0) |
595.81 (65) |
654.11 (0%) |
55000; seq trap 23505; T12 diverge |
pg-birep (#1 Native) |
875.91 |
1,228.60 |
1,231.15 (-71,063) |
1,105.32 (96) |
824.04 (-6%) |
23505 halt; 55000 keyless |
pgedge (#2 Spock LWW) |
556.06 |
818.65 |
2,280.11 (-278,698) |
888.56 (114) |
646.77 (0%) |
23505 transdiscard; LWW loss |
pgedge-delta-apply (#2 CRDT) |
— | — | 1,837.64 (0 drift) |
— | — | Zero drift on delta columns |
bucardo (#9 Trigger) |
735.38 |
1,267.77 |
1,378.79 (-531,620) |
1,232.84 (112) |
763.23 (0%) |
PK req; 23505 sync stall |
citus (#7 Sharded 2PC) |
309.04 |
312.98 |
1,691.45 (0) |
189.44 (9) |
21.67 (-93%) |
0A000 non-dist UNIQUE; 40001 |
yugabyte (#5 DocDB Raft) |
173.64 |
170.19 |
832.65 (0) |
128.24 (0) |
5.78 (-97%) |
40001 (RR); 0A000 LISTEN; 2/3 halt |
cockroach (#6 Pebble Raft) |
42.08 |
74.17 |
471.61 (0) |
44.84 (685) |
10.06 (-76%) |
40001; XCEXF; 42601; 57014 (2/3) |
PostgreSQL 18.6 Target Topologies (results/benchmark_pg18.csv, PG_SCALE = 2)¶
Measured sequentially in the same isolated Docker harness on PostgreSQL 18.6 (Debian 18.6-1.pgdg13+2) with default io_method=worker (io_workers=3) and data_checksums=on (see Solution #17 and Chapter 12):
Topology (#17 PG 18.6) |
A_single_rw TPS |
B2_overlap_rw TPS (Drift) |
D_hot_conflict TPS (Drift) |
E_sysbench_oltp_rw TPS (Failed) |
H_append_only_insert TPS |
F_wan_netem_25ms TPS |
Verified SQLSTATE Limits |
|---|---|---|---|---|---|---|---|
pg18-standalone |
784.43 |
506.21 (0) |
2,117.66 (0) |
1,046.67 (74) |
1,956.76 |
N/A | 23505; 42601 (FOR ALL SEQUENCES) |
pg18-async-streaming |
558.34 |
353.30 (0) |
2,277.43 (0) |
980.72 (75) |
1,423.07 |
554.93 |
25006 RO standby; WAL seq 66\|true |
pg18-sync-streaming |
497.94 |
472.20 (0) |
1,223.75 (0) |
767.63 (76) |
1,760.26 |
41.56 |
25006; SyncRep stall; 25.60 @ 50ms |
pg18-logical |
314.26 |
475.08 (0) |
2,998.37 (0) |
1,027.84 (79) |
3,518.49 |
844.10 |
23505; 42601; 55000 (substream=p) |
pg18-birep (uuidv7()) |
514.28 |
792.45 (-338) |
1,774.11 (-83,252) |
1,055.55 (76) |
2,066.70 (3.30x) |
747.42 |
23503; 23505; 42601; 55000; 7 confl_* |
yt-cluster (#18 cc=half) |
20.63 |
10.69 (0) |
67.76 (0) |
28.48 (12) |
110.53 |
2.25 |
0A000; 40001; 55409; 57P03 (T_REVERT OK) |
yt-cluster-async (#18 nodes>=0) |
41.45 |
55.03 (0) |
163.01 (0) |
124.05 (34) |
224.93 |
4.78 |
40001; 55000; 55409 (2.0x-5.1x vs half, 0 drift) |
Note: yt-cluster / yt-cluster-async ran on 3-node dbinvent/yt:1.21.3 (PG 18.7 + yt_cluster 1.21 / ytserv, results/benchmark_yt_cluster.csv, 36 rows across 18 suites). See Solution #18 and Chapter 06 §7.
Interactive Benchmark Explorer & Logarithmic Charts (log10)¶
Open dashboard/index.html offline in any browser with zero CDN dependencies and an EN/FR switcher. Toggle Baseline PG_SCALE=2 (301 rows) vs Tuned PG_SCALE=20 (318 rows), or open compare. Use 18-topology presets (YT vs Multi-Master), log10/linear axes, L1-L8/T11-T18/PG 18.6/YT tabs, Popularity (22 rows), and CSV export. Browse the 13 charts in Chapter 09 (chart_01-07), Chapter 11 (chart_08-09), and Chapter 12 (chart_10). See Chapter 06 §7–§8 (chart_11) and Chapter 13 (PG_SCALE=20) (chart_12-13).
Live GitHub Pages & PACELC Architecture Selector: Browse the hosted GitHub Pages Benchmark Explorer (Pages workflow tracked in
#506) or open the PACELC Selector tab locally to score all 17 topologies + V5/CRDT variants acrossRPO,WAN RTT, write conflicts, andTCOwith copyableMakefile/./mdbcommands and EN/FR sheet links.









V5 Production-Tuned Highlight (
PG_SCALE=20,318rows,fsync=on,v2.6.1): Applying durable tunings (fillfactor=90,wal_compression=lz4, PG 18/YTio_method=worker/4,-M prepared,5swarm-up, Spockdelta_apply, Citus 1-shard colocation, YugabyteRC + CACHE 1000+ HAProxy:15470, CockroachDBv25.4HAProxy:15480+ non-rootbenchcockroach-rc, YTYT_MAX_PREPARED=300+ parallelytctl+ Leader affinity + Lua55409hook) drivespg18-birepG_c32to4,163.31 TPS, keepspgedgeat0drift (2,125.19 TPSD), lifts CockroachDBv25.47.32xonA(307.95 TPS) andcockroach-rcto040001retries insysbench(153.70 TPS), and acceleratesyt-cluster-asyncE4to189,286.48 TPS(0drift) — see Chapter 13.
Complete Study Navigation (English & French)¶
See the Diataxis Documentation Portal for a goal-based map across Tutorials, How-To Guides, Reference, and Explanation.
Solutions Catalog & Architecture Sheets (19 EN + FR Deep Dives)¶
Every evaluated solution has an EN (docs/en/solutions/) and FR (docs/fr/solutions/) sheet. Each sheet provides Mermaid diagrams, modes, strengths, weaknesses, and verified metrics or exclusion baselines.
Catalog ID Disambiguation (
#16vs#14):pg17-logicaluses#16(T3, native uni-directional logical replication), whereas#14is reserved for Legacy Trigger Systems (Slony-I / Londiste / RubyRep); legacy CSV tables tagpg17-logicalas#14 Baseline.
| Solution & Dedicated Sheet | Product / Docs Link | GitHub Repository | Brief Description |
|---|---|---|---|
| #1 — PostgreSQL 17 Bidirectional Logical | PG 17 Docs | postgres/postgres |
Core PG 16/17+ active-active logical mesh using origin = none (PA/EL) with zero extensions, halting on 23505 PK collisions without autonomous conflict resolution. |
| #2 — pgEdge Platform / Spock v5 | pgEdge Docs | pgEdge/spock · snowflake |
Open-source logical multi-master extension (PA/EL) adding LWW resolution, CRDT delta_apply conflict-free numeric columns, Snowflake IDs, and auto-DDL propagation. |
| #3 — pglogical 2 | pglogical Docs | 2ndQuadrant/pglogical |
Extension-based asynchronous logical replication (PA/EL) offering selective replication sets, configurable conflict policies, and replicate_ddl_command without CRDTs. |
| #4 — EDB Postgres Distributed (PGD/BDR) | EDB PGD Docs | Proprietary / N/A | Commercial bdr multi-master platform pairing async logical replication and CRDTs (PA/EL) with embedded Raft consensus (CAMO, Eager, Write-Lead PC/EC) and pgd-proxy. |
| #5 — YugabyteDB (YSQL + DocDB) | YugabyteDB Docs | yugabyte/yugabyte-db |
Distributed SQL engine (PC/EC) pairing a forked PG C YSQL query layer with DocDB per-tablet Raft consensus (RF=3), HLC ordering, and Wait-on-Conflict READ COMMITTED. |
| #6 — CockroachDB | CockroachDB Docs | cockroachdb/cockroach |
Clean-room Go distributed SQL engine speaking pgwire over Pebble Multi-Raft ranges (RF=3, PC/EC), enforcing strict SERIALIZABLE isolation (40001 retries) by default. |
| #7 — Citus | Citus Docs | citusdata/citus |
Pure PostgreSQL horizontal sharding extension (PC/EC) orchestrating Coordinator + Worker hash shards, 2PC distributed transactions/reference tables, and optional Citus MX. |
| #8 — OpenTenBase / Postgres-XL / XC | OpenTenBase Docs | OpenTenBase/OpenTenBase |
Shared-nothing MPP PostgreSQL fork (PC/EC) with stateless Coordinators, sharded Datanodes, and a centralized Global Transaction Manager (GTM) for 2PC (XC retired, XL dormant). |
| #9 — Bucardo 5 | Bucardo Site | bucardo/bucardo |
External Perl daemon (PA/EL) capturing row changes using PL/Perl triggers into bucardo_delta tables for asynchronous PK-mandatory multi-master batch sync. |
| #10 — SymmetricDS | SymmetricDS Docs | jumpmindinc/symmetric-ds |
Java JVM trigger-based asynchronous engine (PA/EL) staging changes in sym_data for heterogeneous (PG/MySQL/Oracle/SQLite) HTTP/HTTPS edge and mesh batch sync. |
| #11 — PgPool-II | PgPool-II Docs | pgpool/pgpool2 |
C SQL proxy supporting single-primary streaming_replication load balancing/Watchdog HA alongside fragile statement-broadcast replication and snapshot_isolation (PC/EC) modes. |
| #12 — AWS Aurora Limitless (& MM v1) | AWS Aurora Limitless Docs | Proprietary / N/A | Managed AWS sharded engine (PC/EC) pairing Transaction Routers, Data Access Shards, 4/6 AZ storage quorum, and Time Sync MVCC 2PC (superseding retired Aurora MM v1). |
| #13 — GCP Spanner PG & AlloyDB | Spanner PG · AlloyDB | Proprietary / N/A | Contrasts Spanner PG Interface (PGAdapter, Multi-Paxos + TrueTime external consistency PC/EC) with AlloyDB's single-primary disaggregated storage and read pools. |
| #14 — Legacy Trigger Systems (EOL) | Slony-I · Londiste | slony1-engine · londiste · rubyrep |
Retired/EOL pre-pgoutput trigger/queue replicators (PA/EL) — single-origin cascading Slony-I/Londiste+PGQ and abandoned JRuby RubyRep — retained as historical baselines. |
| #15a — PostgreSQL 17 Standalone | PG 17 Docs | postgres/postgres |
Single-writer PostgreSQL 17 control baseline using local WAL fsync (CA) with zero replication overhead to quantify multi-master coordination cost. |
| #15b — PG 17 Physical Streaming & Patroni | PG 17 HA · Patroni | postgres/postgres · patroni/patroni |
Single-primary physical block-level WAL streaming (async PA/EL or sync PC/EC RPO=0) orchestrated by Patroni, etcd Raft DCS, and HAProxy failover. |
| #16 — PG 17 Uni-Directional Logical | PG 17 Logical Docs | postgres/postgres |
Built-in PG 17 pgoutput publish/subscribe row replication (PA/EL) decoupling storage and major versions (T3, zero-downtime upgrades, selective filtering). |
| #17 - PostgreSQL 18.6 Native Clustering (AIO, uuidv7, Streaming & Logical) | PG 18 Docs | postgres/postgres |
Core PG 18.6 target stack across all 5 native tiers adding AIO worker, default data_checksums=on, native uuidv7() active-active PKs, 7 confl_* counters, substream=p, and 42601 sequence sync deferral. |
| #18 - YT Cluster & YT Cluster Lite | YT Overview / Docker Hub / agent.md / Jepsen | DBinvent/yt-cluster-lite |
Unmodified PG 18 + row triggers + Rust ytserv XA 2PC (cc=half), zero drift (55409/40001), DROP EXTENSION reversibility; MIT embedded leaf/ext vs dbinvent/yt PolyForm/Commercial. |
Reproducible Lab Stacks, multi-db-docker-env Submodule & Makefile¶
PoC topologies, T11–T18 suites, and V2 benchmarks use jmrenouard/multi-db-docker-env (env/multi-db-docker-env). See stacks/README.md and results/ for mappings and raw CSV/JSON data:
Submodule Compose (env/multi-db-docker-env/) |
Topology | Primary Images |
|---|---|---|
docker-compose-pg17-baseline.yml |
PG 17 Standalone & Sync Streaming | postgres:17 |
docker-compose-pg-streaming.yml / pg-logical.yml |
PG 17 Async Streaming & Uni-Logical | postgres:17 |
docker-compose-pg-birep.yml |
PG 17 Bidirectional (origin=none) + HAProxy |
postgres:17, haproxy:lts-alpine |
docker-compose-pgedge.yml |
3-Node pgEdge Spock 5.0.14 + Snowflake + HAProxy |
ghcr.io/pgedge/pgedge-postgres:17-spock5-minimal |
docker-compose-bucardo.yml |
2-Node PG 17 (plperl) + Bucardo 5.6.0 Daemon |
Custom postgres:17 + debian:trixie-slim |
docker-compose-citus.yml |
Citus 14.2.0 (1 Coordinator + 2 Workers) |
citusdata/citus:14.2.0-pg17 |
docker-compose-yugabyte.yml |
3-Node YugabyteDB RF=3 YSQL + DocDB + HAProxy :15470 |
yugabytedb/yugabyte:2026.1.3.0-b100, haproxy:lts-alpine |
docker-compose-cockroach.yml |
3-Node CockroachDB RF=3 Multi-Raft + HAProxy :15480 |
cockroachdb/cockroach:latest-v25.4, haproxy:lts-alpine |
docker-compose-pg18-streaming.yml |
PG 18.6 Standalone, Async & Sync Streaming (AIO worker) |
postgres:18 (18.6) |
docker-compose-pg18-logical.yml |
PG 18.6 Uni-Directional Logical (substream=p, pubgencols=s) |
postgres:18 (18.6) |
docker-compose-pg18-birep.yml |
PG 18.6 Bidirectional Logical (origin=none, uuidv7()) + HAProxy |
postgres:18 (18.6), haproxy:lts-alpine |
docker-compose-yt-cluster.yml |
3-Node YT Cluster 1.21.3 (yt_cluster + ytserv XA 2PC) |
dbinvent/yt:1.21.3 (PG 18.7) |
Common Commands¶
# Initialize the multi-db-docker-env Git submodule (13 Compose stacks; v2.6.4 benchmark harness)
make init-env
make help
# Run unit tests (security, math, 13 charts, dual-dataset 18-topology dashboard) and Compose/Bash lint
make test && make lint
# Run topology lifecycle, benchmarks (V1/V2 + PG 18.6 + YT + V5 Scale=20), charts, and dashboard
cp .env.example .env
make build-bench-image # Build multi-db-pgbench-sysbench:latest from scripts/Dockerfile.bench
make up-pgedge && make test-pgedge && make down-pgedge
make bench-all && make bench-pg18 && make bench-yt-cluster && make bench-optimized && make popularity && make charts && make dashboard
make pages-build && make pages-check # Stage & verify offline GitHub Pages bundle in _site/
Governance, Security & Honest Scope¶
- Living Registers: Every engineering decision, bug RCA, dead-end, and simplification is tracked in
docs/ACTION_LOGBOOK.mdanddocs/RCA_REGISTER.md. - Credential Hygiene: Repository files hold zero real passwords or host paths. Containers read defaults from
.env.example. - Threats to Validity: Local benchmarks share one 20-vCPU / 16.4 GiB NVMe host. We modeled WAN delay with
tc netem(25 ms), not separate regions (see Chapter 05).
Support & Attribution¶
Jean-Marie Renouard (jmrenouard) authors this series under the MIT License. LightPath provides engineering and infrastructure support:
Supported by