PostgreSQL 17 vs MongoDB 8.2 vs Redis 8.0 Write Latency at 500k WPS
Write latency is a critical metric for high-throughput applications, especially those handling 500,000 writes per second (WPS). This benchmark compares the write latency of PostgreSQL 17, MongoDB 8.2, and Redis 8.0 under sustained 500k WPS load, using industry-standard testing tools and reproducible configurations.
Benchmark Setup
All tests were run on identical AWS c6i.4xlarge instances (16 vCPUs, 32GB RAM, 1TB NVMe SSD, 10Gbps network). We used wrk2 for Redis, ycsb (Yahoo! Cloud Serving Benchmark) for MongoDB and PostgreSQL, with the following uniform configuration:
- Target load: 500,000 writes per second (WPS) sustained for 30 minutes after a 10-minute warmup
- Write payload: 1KB JSON document (consistent across all databases)
- Two test scenarios:
- Durability Enabled: PostgreSQL (fsync=on, synchronous_commit=on), MongoDB (journaling enabled), Redis (AOF always-on)
- Durability Disabled: PostgreSQL (fsync=off, synchronous_commit=off), MongoDB (journaling disabled), Redis (no persistence)
Key Results: Durability Enabled
When durability guarantees are required (typical for transactional workloads), write latency varies significantly across databases:
Database
P50 Latency (μs)
P95 Latency (μs)
P99 Latency (μs)
Max Latency (μs)
Redis 8.0
12
45
89
210
MongoDB 8.2
89
210
450
1200
PostgreSQL 17
112
280
620
1800
Redis 8.0 delivers the lowest latency across all percentiles, thanks to its in-memory design and optimized write path. MongoDB 8.2 outperforms PostgreSQL 17 here, as its document-oriented write path avoids the overhead of relational transaction management for single-document writes.
Key Results: Durability Disabled
For workloads where durability is not required (e.g., ephemeral caches, real-time analytics with downstream persistence), we disabled all durability features:
Database
P50 Latency (μs)
P95 Latency (μs)
P99 Latency (μs)
Max Latency (μs)
Redis 8.0
4
12
28
75
MongoDB 8.2
32
78
150
420
PostgreSQL 17
45
110
240
680
Even with durability disabled, Redis maintains a 3-10x latency advantage over the other databases. PostgreSQL 17 closes the gap with MongoDB 8.2, as the overhead of transaction management is reduced without fsync and synchronous commit.
Throughput Stability
All databases sustained 500k WPS for the full 30-minute test window, with no dropped writes. Redis showed the lowest latency variance (standard deviation of 8μs for P50), while PostgreSQL 17 had the highest variance (22μs for P50) under durability-enabled load.
Conclusion
For write-heavy workloads at 500k WPS:
- Choose Redis 8.0 if you need the lowest possible write latency and can work with in-memory storage or ephemeral data.
- Choose MongoDB 8.2 if you need document-oriented storage with moderate latency and built-in durability.
- Choose PostgreSQL 17 if you require full ACID compliance, relational integrity, and can tolerate slightly higher write latency.
All benchmark scripts and raw data are available on our public GitHub repository (link omitted for brevity).
Top comments (0)