VPS vs Bare Metal for Database Workloads: Real Benchmarks for MySQL, PostgreSQL, and MongoDB

Database performance is the most workload-dependent variable in infrastructure decisions. A VPS might handle web serving beautifully but choke on OLTP database workloads that a bare metal server eats for breakfast — or vice versa. We ran real benchmarks on MySQL, PostgreSQL, and MongoDB across both VPS and bare metal environments to settle the question with data, not opinions.

Test Methodology

  • VPS configuration: 4 vCPU, 16 GB RAM, 160 GB NVMe (KVM, dedicated host)
  • Bare metal configuration: AMD EPYC 7282 (8 cores), 32 GB RAM, 2× NVMe RAID-0
  • Benchmark tools: sysbench (MySQL/PostgreSQL), mongodb-perf (MongoDB)
  • Each test: Run 5 times, median reported. Tables scaled to 10M rows.

MySQL 8.0 Results

WorkloadVPS (4 vCPU / 16 GB)Bare Metal (8C / 32 GB)VPS % of Bare Metal
OLTP Read/Write (TPS)4,8208,15059%
Read-Only (QPS)38,40052,10073%
Write-Only (QPS)12,10024,30049%
Point Select (latency, ms)0.310.19
Range Select (latency, ms)2.11.3

Key takeaway: Write-heavy MySQL workloads see the biggest gap. The hypervisor introduces latency for fsync operations, which directly impacts write throughput. If your app does more than 70% writes, bare metal is worth the premium.

PostgreSQL 16 Results

WorkloadVPS (4 vCPU / 16 GB)Bare Metal (8C / 32 GB)VPS % of Bare Metal
OLTP Read/Write (TPS)3,9507,21054%
Read-Only (QPS)31,20046,80066%
Write-Only (QPS)9,80021,50045%
Vacuum (duration)14.2s7.8s
Checkpoint (duration)3.1s1.4s

Key takeaway: PostgreSQL’s MVCC and checkpoint behavior amplifies the VPS disadvantage. Vacuum and checkpoint operations rely heavily on sequential I/O, and the hypervisor’s I/O scheduling adds latency variance. For analytical workloads with large sequential scans, bare metal is 1.5–2× faster.

MongoDB 7.0 Results

WorkloadVPS (4 vCPU / 16 GB)Bare Metal (8C / 32 GB)VPS % of Bare Metal
Read Ops/sec29,40038,20077%
Write Ops/sec14,20025,10056%
Update Ops/sec11,80021,40055%
Index Scan (latency, ms)0.420.28
Aggregation (latency, ms)4.72.9

Key takeaway: MongoDB’s in-memory engine and document model narrow the gap for read operations — the VPS achieves 77% of bare metal read throughput. However, write operations with journaling enabled still incur the fsync penalty, widening the gap to ~55%.

When to Choose VPS vs. Bare Metal for Databases

Workload ProfileRecommendationRationale
Read-heavy web app (>80% reads)VPS (high-RAM plan)Cache absorbs read latency; hypervisor overhead minimal
Write-heavy OLTPBare metalfsync latency on VPS cuts write throughput ~50%
Analytics / data warehousingBare metalSequential scan throughput is 1.5–2× on bare metal
Development / staging DBVPSCost savings of 60–70% over bare metal
MongoDB read-heavyVPSOnly 23% gap vs bare metal — VPS value wins
MongoDB write-heavyBare metal or high-end VPSJournaling fsync penalty still significant

Optimizing VPS for Database Workloads

If you’re committed to a VPS but need better database performance:

  • Tune the query cache — MySQL’s buffer pool and PostgreSQL’s shared_buffers should be 50–70% of available RAM
  • Use NVMe-backed VPS — storage I/O is the bottleneck; NVMe drops latency by 10× vs SATA SSD
  • Pin CPUs — some providers offer CPU pinning to reduce steal time variance
  • Avoid oversubscribed hosts — monitor /proc/stat for steal time; >3% means the host is oversubscribed
  • Use connection pooling — PgBouncer or ProxySQL reduces per-connection overhead that’s amplified under virtualization

Choosing the right VPS provider for database workloads starts with understanding their virtualization stack and storage infrastructure. See our VPS provider comparison table for real-world database benchmarks across providers to find the best fit for your workload.

Leave a Reply