Back to Connect

PostgreSQL Benchmark Results

docs/benchmark-results/postgres.md

4.90.24.7 KB
Original Source

PostgreSQL Benchmark Results

Environment: Intel Core i7-10850H @ 2.70GHz, 32 GB RAM, WSL2 (Linux 6.6.87.2), x86_64

See internal/impl/postgresql/bench/ for configs and run instructions.


CDC / Snapshot — Small Rows (cart table)

Full snapshot of public.cart: 10,000,000 rows × ~600 B. Varying GOMAXPROCS and batching.count.

msg/sec

GOMAXPROCSbatch=1000batch=5000batch=10000
1134,287130,555129,603
2212,852218,055214,555
4276,259296,138264,454
8300,760318,660284,733
(unbounded)211,111

MB/sec

GOMAXPROCSbatch=1000batch=5000batch=10000
1817878
2128131129
4166178159
8181192171
(unbounded)127

Observations:

  • Core scaling is strong up to 4 cores (1→2: ~1.58×, 2→4: ~1.30×), then plateaus (4→8: ~1.09×).
  • batch=5000 is the sweet spot — consistently fastest across all core counts.
  • batch=10000 regresses at higher core counts due to memory pressure and pipeline stall time waiting to fill a batch.
  • At 1 core, batch size has no effect (~130K msg/sec), confirming the bottleneck is connector read throughput, not batch assembly.

CDC / Snapshot — Large Rows (users table)

Full snapshot of public.users: 150,000 rows × ~625 KB. I/O bound workload.

msg/sec

GOMAXPROCSbatch=1000batch=5000batch=10000
1883843N/A
21,1661,1341,024
41,145N/AN/A
81,145N/AN/A

MB/sec

GOMAXPROCSbatch=1000batch=5000batch=10000
1580554N/A
2766745673
4752N/AN/A
8752N/AN/A

Observations: Throughput plateaus at 2 cores (1,166 msg/sec, 766 MB/sec) and is flat from 4→8 cores — purely I/O bound. Additional cores provide no benefit. Contrast with cart where throughput scaled to 318K msg/sec at 8 cores.


Kafka → PostgreSQL: Redpanda Connect vs Kafka Connect (JDBC Sink)

Both connectors read from a 16-partition bench-events Kafka topic and write to a bench_events PostgreSQL table. Dataset: 10,000,000 rows × ~200 B (synthetic events: id, category, value, ts).

See internal/impl/postgresql/bench/kafka-connector/ for setup.

Comparison (best configuration per connector)

ConnectorConfigurationElapsedThroughput
Kafka Connect (JDBC Sink)16 tasks, batch=300055s181,818 msg/s
Redpanda Connectmif=6470s130,952 msg/s

Kafka Connect is ~1.39× faster on this workload. Its JDBC sink tasks amortise PostgreSQL round-trips more aggressively than RPCN's sql_insert output bounded by max_in_flight.

Redpanda Connect tuning runs

max_in_flightGOMAXPROCSKafka CPUsElapsedThroughput
16uncappeduncapped88s103,825 msg/s
64uncappeduncapped70s130,952 msg/s
128uncappeduncapped96s104,166 msg/s
1284uncapped96s104,166 msg/s
1288uncapped145s68,965 msg/s
12841121s70,300 msg/s
64uncapped289s112,359 msg/s
64uncapped3101s99,009 msg/s

Observations:

  • Sweet spot: mif=64, uncapped Kafka — 130,952 msg/s.
  • Increasing max_in_flight beyond 64 causes PostgreSQL connection contention and hurts performance.
  • Adding GOMAXPROCS cores degrades throughput — the bottleneck is PostgreSQL write throughput, not CPU.
  • Capping Kafka CPU below 2 cores throttles fetch throughput and becomes the new bottleneck.