In this blog post, we’ll compare the performance of PostgreSQL’s pgbench
across various hardware platforms and configurations. The benchmarking test will focus on how different CPUs affect transaction processing time and throughput under the same load conditions. Our goal is to assess how PostgreSQL scales on Intel Xeon, Apple M1, and Apple M4 CPUs.
What is pgbench?
pgbench
is a benchmarking tool that comes with PostgreSQL. It runs a series of transactions, testing the database’s performance under various load conditions. For this test, we will use the default TPC-B (sort of) benchmark, which simulates a banking workload.
We’ll focus on the following metrics:
- Latency Average: The average time it takes to process a transaction.
- Transactions Per Second (TPS): The number of transactions processed per second. We’ll include two variations: with and without the initial connection time.
- Initial Connection Time: The time it takes to establish a connection to the database server.
Test Setup
For each case, we used the following configuration:
- Number of clients: 10
- Number of transactions per client: 1000
- Total transactions processed: 10,000 (10 clients x 1000 transactions each)
- Query Mode: Simple queries
Let’s dive into the results.
Case 1: Intel Xeon Silver 4110 CPU @ 2.10GHz
Hardware: Intel Xeon Silver 4110
CPU: 8 cores, 16 threads
Database: PostgreSQL running on a standard Linux server
Benchmark Results:
- Latency Average: 12.847 ms
- Initial Connection Time: 102.141 ms
- TPS (Excluding Connection Time): 778.37
The Intel Xeon Silver 4110 shows respectable performance but lags behind in comparison to more modern processors. While the latency average is relatively low, the transactions per second (TPS) are on the lower end. This can likely be attributed to both the older architecture and the higher initial connection time, which can impact the overall performance for workloads with frequent connections.
Case 2: Intel Xeon Gold 6133 CPU @ 2.50GHz
Hardware: Intel Xeon Gold 6133
CPU: 8 cores, 16 threads
Database: PostgreSQL running on a similar Linux server configuration
Benchmark Results:
- Latency Average: 4.796 ms
- Initial Connection Time: 34.393 ms
- TPS (Excluding Connection Time): 2084.87
The Intel Xeon Gold 6133, being a more modern and higher-end processor, demonstrates a substantial improvement over the Silver 4110 model. Latency is cut down by more than half, and the TPS is more than twice as high. The significant drop in initial connection time also contributes to better throughput for short-lived database connections.
Case 3: Apple M1 CPU
Hardware: Apple M1
CPU: ARM-based, 8 cores
Database: PostgreSQL running on the 15 version of Postgres.app
Benchmark Results:
- Latency Average: 0.867 ms
- Initial Connection Time: N/A (test excludes this)
- TPS (Excluding Connection Time): 11,532.72
The Apple M1 chip is a game changer for databases running on ARM-based processors. Even with 10 clients, the M1 excels with a latency average that is nearly 1 ms, and an incredible TPS performance, outperforming the Intel Xeon processors by a factor of five. The low latency and high throughput are likely due to the efficiency and performance of the M1 chip, which integrates CPU and memory in a unified architecture for faster data processing.
Case 4: Apple M4 CPU
Hardware: Apple M4
CPU: ARM-based, 10 cores (anticipated improvements over M1)
Database: PostgreSQL running on the 15 version of Postgres.app
Benchmark Results:
- Latency Average: 0.591 ms
- Initial Connection Time: 111.438 ms
- TPS (Excluding Connection Time): 16,919.21
The Apple M4 takes the crown in this comparison, offering an even more significant performance boost over the M1. With a latency of 0.591 ms, it performs nearly 8 times faster than the Intel Xeon Gold 6133 model. The TPS jumps to almost 17,000, which is a massive leap from the Intel-based servers. Even though the connection time is a bit higher compared to the M1, the M4’s speed easily overcomes this.
Performance Comparison and Key Insights
CPU | Latency Average (ms) | TPS (Excluding Connection Time) | % |
---|---|---|---|
Intel Xeon Silver 4110 | 12.847 | 778.37 | 100% |
Intel Xeon Gold 6133 | 4.796 | 2084.87 | 268% |
Apple M1 | 0.867 | 11,532.72 | 1487% |
Apple M4 | 0.591 | 16,919.21 | 2174% |
- Apple M4 clearly offers the best performance, with the lowest latency and highest TPS, easily surpassing both Intel Xeon processors.
- Intel Xeon Gold 6133 is a solid performer, with a clear advantage over the Silver 4110 model, showing that newer and more powerful Intel CPUs can scale well with PostgreSQL.
- Intel Xeon Silver 4110 shows decent performance but lags behind both the Gold version and the Apple M1/M4, particularly in transaction throughput.
Conclusion
This benchmark highlights the rapid evolution of CPU architectures. While Intel Xeon CPUs, especially the Gold series, still perform well in enterprise environments, the Apple M1 and M4 chips demonstrate a remarkable leap in performance for PostgreSQL workloads, particularly for environments optimized for ARM processors. If your organization uses PostgreSQL and is considering hardware upgrades, the Apple M1 and M4 chips could provide significant performance gains, especially when working with high-concurrency workloads or latency-sensitive applications.
As we continue to see innovation in ARM-based processors, we can expect the performance gap between traditional x86-based servers and newer ARM-based systems to continue shrinking, if not completely reversing.
Stay tuned for future comparisons as more powerful hardware becomes available!