ENGINEERING REFERENCE / DB / 015

VPS for Database: PostgreSQL & MySQL Sizer

Plan database buffers, memory headroom and storage around active data and writes.

Reference specifications

STATIC / DEFAULTS

Each row includes a distinct workload, estimated index and log space, plus maintenance capacity.

Database workloadMinimumRecommendedHeadroom
Small read-heavy database2 vCPU / 4 GB RAM / 30 GB disk2 vCPU / 4 GB RAM / 40 GB disk2 vCPU / 8 GB RAM / 50 GB disk
SaaS PostgreSQL primary4 vCPU / 16 GB RAM / 80 GB disk4 vCPU / 24 GB RAM / 105 GB disk4 vCPU / 24 GB RAM / 130 GB disk
Write-heavy transactional database4 vCPU / 48 GB RAM / 195 GB disk6 vCPU / 48 GB RAM / 250 GB disk6 vCPU / 64 GB RAM / 310 GB disk
01 / DATA RESIDENCY

Separate buffer memory from the working set

Database memory layers and disk allocations for data, indexes, logs and maintenance.
Database cache, operating-system cache and maintenance space are distinct budget items.

Reference sizing tiers

Tier Scenario inputs CPU RAM Storage Catalog price Network at price endpoints
Minimum engine=postgresql; connections=20; datasetGb=8; hotPercent=50; writePercent=15; replication=false 2 vCPU · shared x86_64 8 GB 30 GB NVMe/SSD $6.60–$96.00 USD/mo Contabo Cloud VPS 4 (Core VPS) (Unmetered); Vultr High Frequency 16 GB (5 TB)
Recommended engine=postgresql; connections=20; datasetGb=8; hotPercent=50; writePercent=15; replication=false 2 vCPU · shared x86_64 8 GB 40 GB NVMe/SSD $6.60–$96.00 USD/mo Contabo Cloud VPS 4 (Core VPS) (Unmetered); Vultr High Frequency 16 GB (5 TB)
Comfortable engine=postgresql; connections=20; datasetGb=8; hotPercent=50; writePercent=15; replication=false 4 vCPU · shared x86_64 8 GB 50 GB NVMe/SSD $6.60–$96.00 USD/mo Contabo Cloud VPS 4 (Core VPS) (Unmetered); Vultr High Frequency 16 GB (5 TB)

Use the RAM calculator to budget memory for services sharing the host, and the bandwidth calculator for off-host backups and replication.

Begin with the hot fraction

Logical dataset size is the uncompressed application data entered by the operator. The hot working set is the portion accessed frequently enough to benefit from memory. This model starts the database buffer target at 35% of that hot set, with a 0.5 GB floor, and reserves another 35% for operating-system page cache. It then adds one GB for the OS, 25 MB per active pooled connection and at least 0.25 GB for concurrent work. The result is a heuristic, not a universal tuning formula.

PostgreSQL shared_buffers and the InnoDB buffer pool have different behavior. Neither represents all resident database memory. Sorts, hash operations, maintenance, extensions, replication and kernel caches consume additional space. PostgreSQL work_mem is per operation rather than a global ceiling: several nodes and sessions may allocate it simultaneously. Measure the actual query plan and keep a margin for peak overlap.

Pool sessions before enlarging hardware

Active pooled connections differ from registered users and idle application sockets. PgBouncer can multiplex suitable PostgreSQL workloads, but transaction pooling changes session semantics and requires compatibility checks. Set sensible database connection limits, observe waits and analyze long transactions. MySQL and MariaDB pools also need limits that reflect the real concurrency and query duration.

Space, random I/O and write amplification

The storage budget adds 30% of logical data for indexes and another 30% for maintenance, plus a minimum four GB for WAL or binary logs and 12 GB for the system. Enabling retention increases the log allowance. Actual indexes, replicas, long-running transactions, vacuum activity and restore operations can exceed these estimates. Put independent backups in another failure domain and rehearse a restore.

The displayed IOPS figure is a planning target derived from connection count, write percentage and hot data size, not an observed device result. Capacity in GB says little about sustained random write latency. Check provider IOPS caps, burst credits, fsync behavior and tail latency with a representative dataset. Confirm whether storage is local NVMe or network-attached and whether ECC memory is specified.

02 / QUERY VALIDATION

Protect tail latency under write pressure

A dedicated vCPU can reserve scheduling capacity and reduce one source of noisy-neighbor variation; it does not eliminate disk stalls, locks or checkpoint bursts. The model selects dedicated capacity when pooled concurrency reaches 40 or the write mix reaches 35%. Those are operational flags, not universal thresholds. Track p99 query latency, lock waits, replication lag and checkpoint behavior before and after a change.

Inspect WAL retention slots and binary-log expiration regularly. A disconnected replica or a failed archive target can accumulate files until the volume fills. Alerts should cover remaining space, growth rate and backup freshness. Review the processor reference, web stack sizer, game workload guide and FFmpeg planning guide for adjacent host requirements.

FIELD NOTES / FAQ

Frequently asked questions

Why are NVMe IOPS different from disk capacity?

Capacity measures stored bytes; IOPS and latency describe operations over time. Provider caps, workload mix and burst limits affect sustained performance.

How much PostgreSQL shared_buffers should I allocate?

Start with a measured working set and leave space for OS cache, sessions, work_mem and maintenance. The displayed target is an assumption to benchmark, not a universal setting.

Can PgBouncer reduce connection pressure?

A compatible pool can multiplex application connections onto fewer database sessions. Check transaction-pooling limitations and monitor queueing.

Why can WAL or binary logs fill the disk?

Replication slots, broken archiving or retention settings can prevent cleanup. Monitor lag, disk growth and recovery requirements before changing retention.

Why might dedicated vCPU improve p99 query latency?

Reserved scheduling reduces one source of CPU contention. Locks, I/O stalls, bad plans and checkpoints can still dominate tail latency.

Does the database estimate include an off-host backup?

No. Retain and test independent backups in another failure domain; local maintenance capacity is not a backup.