How to choose a VPS for a database
A database on your own VPS means a predictable price and full control over the settings: you can install the version you need, enable extensions and set up backups your way. Managed cloud databases are more convenient, but cost several times more for the same amount of memory. If you're prepared to handle updates and backups yourself, a database server pays for itself quickly.
Memory matters more than cores
Databases keep hot data in RAM: PostgreSQL in shared_buffers and the filesystem cache, MySQL and MariaDB in the InnoDB buffer pool, Redis keeps everything there. As long as the working set fits in memory, queries return in milliseconds; once it stops fitting, every query goes to disk and speed drops by an order of magnitude or more. So first estimate the size of your active data and choose memory with headroom:
- up to 5 GB of data — a blog, a small shop, a bot backend: 2 GB of RAM is enough;
- 10–30 GB — a CRM, an online store with a catalog, analytics: from 4 GB, preferably 8 GB;
- over 50 GB or hundreds of queries per second — 16 GB or more and dedicated cores.
Cores are needed for parallel queries and heavy reports. For a typical web workload 2 cores are enough, and the table above is sorted by price per gigabyte of memory by default — the key metric for a database.
Storage: NVMe only
A database constantly performs small random reads and writes, and the transaction log needs fast synchronous writes. On HDDs and cheap shared SATA SSDs this turns into latency and stalls at every checkpoint. Choose NVMe plans and plan for three times your current data size: indexes, WAL or binlog files, temporary sort files and local backups take up at least as much as the tables themselves.
PostgreSQL, MySQL or Redis
- PostgreSQL — the all-round choice for new projects: strict transactions, JSON, full-text search, extensions such as PostGIS. More on its requirements on the VPS for PostgreSQL page.
- MySQL and MariaDB — the standard for WordPress, Bitrix and most CMSs; they use less memory at small data sizes. See VPS for MySQL.
- Redis — caching, queues and sessions; everything is stored in memory, so memory size is what determines the plan. See VPS for Redis.
Security and backups
Never expose your database port to the internet: PostgreSQL (5432), MySQL (3306) and Redis (6379) should listen only on 127.0.0.1 or a private network. If the application runs on another server, connect them through WireGuard or an SSH tunnel. Scanners find exposed databases within hours, and ransomware gangs encrypt the data.
A backup on the same server is not a backup. Set up a daily dump (pg_dump, mysqldump) or continuous log archiving and copy it somewhere else: to object storage or to a separate backup VPS. Once a month, check that you can actually restore from the copy.
Where to host it
Put the database in the same data center as the application: every extra 30–50 ms of network latency is multiplied by the number of queries per page. If you store personal data of Russian citizens, Federal Law 152-FZ requires the database to be in Russia — for that there's the VPS in Russia selection.