PostgreSQL can run on a small VPS, but database workloads become sensitive to memory, storage latency, CPU consistency, and backup design much sooner than a simple web server. The correct VPS size depends on dataset size, active working set, query patterns, connections, and how much of the database can remain cached.
The cheapest VM is rarely the right optimization target for an important production database.
Key takeaways
- 4 GB is a practical starting point for many small production PostgreSQL databases.
- More RAM can improve cache hit rates, but bad queries still need fixing.
- Fast consistent storage matters for write-heavy and transactional workloads.
- Keep the application close to the database.
- Use logical or physical database backups in addition to infrastructure snapshots.
How much RAM for PostgreSQL?
Small databases can run in 2 GB, but 4 GB provides more useful room for PostgreSQL buffers, the operating system cache, application processes, and maintenance tasks. Eight gigabytes or more becomes attractive as the working set and concurrency grow.
Tune memory settings to the actual server. Values copied from a larger database host can cause swapping or out-of-memory failures on a small VPS.
CPU and query performance
Shared CPU is acceptable for small bursty databases. Dedicated or more predictable CPU becomes useful when queries run continuously or latency consistency matters.
Indexing and query design still matter more than buying cores blindly. Measure slow queries before scaling hardware.
Storage and durability
PostgreSQL performs frequent reads, writes, fsync operations, checkpoints, and WAL activity. Consistent SSD or NVMe storage can improve latency, especially for transactional systems.
Understand whether the VPS disk is local, replicated, or network-attached and how snapshots behave during database writes.
Backups and application placement
Keep the application in the same region as PostgreSQL to avoid repeated network latency on every query. For critical systems, use PostgreSQL-aware backups and test recovery.
A provider snapshot can complement database backups but should not be the only recovery method.
Frequently asked questions
Is 2 GB RAM enough for PostgreSQL?
It can be for a small database, but 4 GB is a more comfortable production starting point.
Does PostgreSQL need NVMe?
Not always, but write-heavy and latency-sensitive workloads can benefit from faster consistent storage.
Shared or dedicated CPU for PostgreSQL?
Shared CPU can work for small databases; sustained production workloads benefit from more predictable compute.
Should PostgreSQL be on the same VPS as the app?
It can be for small systems. As scale or reliability needs grow, separating the database can simplify independent scaling and recovery.