Database servers on a VPS

A database is fast when its working set fits in RAM, so size by data, not by users. S8 (4 vCPU, 8 GB RAM, 80 GB NVMe) suits most small apps; steady production loads belong on D16 with dedicated threads.

Recommended start: P4, $12.05/mo

How big should the buffer pool or shared_buffers be?

Enough to hold the data and indexes your queries touch every day, plus room for connections and the OS. That set is usually far smaller than the database on disk.

Check it on a running system. In PostgreSQL, SELECT pg_size_pretty(pg_database_size(current_database())); gives total size, and the cache hit ratio from pg_stat_database should stay above 99%. In MySQL, compare Innodb_buffer_pool_reads to Innodb_buffer_pool_read_requests; disk reads should be well below 1% of requests.

Database sizeTypical hot setPlan
under 5 GB1~2 GBP4 or S4
5~30 GB3~6 GBS8
30~100 GB8~12 GBD16
100~200 GB16~24 GBD32

Which family suits a production database?

For steady production load, Dedicated CPU. Query latency is only as consistent as the CPU under it, and dedicated threads keep the slow tail of your queries predictable during busy hours.

The Shared vCPU family is a sound choice for internal tools, reporting copies and databases that are idle most of the day; it gives the most RAM for the money in Europe. Place the database in the same city as the application servers that query it. Each query crosses the network at least once, and 20 ms between cities turns a page with 30 queries into a slow page. Every plan stores data on local NVMe, which handles random reads far better than network storage.

Plans that fit

Sizes picked for this project, smallest first. Prices are per month; the order total is the shortest term that reaches $40.

PlanWhySizePer monthOrder from
P4Small app databases outside Europe2 vCPU, 4 GB RAM, 80 GB NVMe$12.05$72.30 for 6 months
S8Most small apps: 5~30 GB of data, buffer pool of 4~5 GB4 vCPU, 8 GB RAM, 80 GB NVMe$6.35$76.20 for 12 months
D8Steady query latency with an 8 GB budget2 vCPU, 8 GB RAM, 80 GB NVMe$25.85$77.55 for 3 months
D16Production PostgreSQL or MySQL with a 30~100 GB dataset4 vCPU, 16 GB RAM, 160 GB NVMe$51.95$51.95 for 1 month
D32Larger datasets that need 16~24 GB of cache8 vCPU, 32 GB RAM, 240 GB NVMe$83.45$83.45 for 1 month

How do I tune PostgreSQL for the plan?

Install from the distribution (apt -y install postgresql on Ubuntu 24.04 gives version 16) and edit /etc/postgresql/16/main/postgresql.conf. Example values for D16 with 4 vCPU, 16 GB RAM, 160 GB NVMe:

shared_buffers = 4GB
effective_cache_size = 12GB
work_mem = 32MB
maintenance_work_mem = 1GB
max_connections = 100
random_page_cost = 1.1
wal_compression = on

The rule of thumb behind these numbers: shared_buffers around 25% of RAM, effective_cache_size around 75%, and random_page_cost near 1 because NVMe random reads are nearly as fast as sequential ones. Put PgBouncer in front if the app opens many short connections; each PostgreSQL backend costs several MB.

How do I tune MySQL or MariaDB?

InnoDB keeps data and indexes in its buffer pool, so that one setting matters most. On a server that only runs the database, give it 60~70% of RAM. In /etc/mysql/mariadb.conf.d/50-server.cnf (or /etc/mysql/mysql.conf.d/mysqld.cnf) for S8:

[mysqld]
innodb_buffer_pool_size = 5G
innodb_log_file_size = 1G
innodb_flush_method = O_DIRECT
max_connections = 200
tmp_table_size = 64M
max_heap_table_size = 64M

Restart with systemctl restart mariadb and watch memory with free -m for a day. If the app shares the server, lower the pool so PHP or Node.js still has room. For Redis, always set maxmemory and an eviction policy such as allkeys-lru in /etc/redis/redis.conf, or it will grow until the kernel kills it.

How do I let the app reach the database safely?

Servers talk over their public addresses, so restrict access by IP and encrypt the connection. Never leave a database port open to the whole internet.

  • PostgreSQL: set listen_addresses = '*', then allow only your app server in pg_hba.conf with hostssl appdb appuser 198.51.100.20/32 scram-sha-256.
  • MySQL: bind-address = 0.0.0.0, create the user as 'app'@'198.51.100.20' and require TLS.
  • Firewall: ufw allow from 198.51.100.20 to any port 5432 proto tcp; leave everything else closed.
  • For a single app server, a WireGuard tunnel between the two machines is another tidy option.

How should database backups work?

Use two layers: the disk-level backup add-on and your own logical dumps. Disk copies restore the whole server to a given day; dumps let you restore one table or move to a new server.

The add-on keeps seven daily copies for +20% of the plan price; on D16 that is $10.39 a month. For dumps, a nightly cron job such as pg_dump -Fc appdb > /var/backups/appdb-$(date +%F).dump or mariadb-dump --single-transaction appdb | gzip works well. Copy the files off the server with rsync or restic, and test a restore every month. See backups and restore.

How much does a database server cost?

S8 is $6.35 a month, sold as $76.20 for 12 months. D16 with dedicated threads is $51.95 a month and can be paid monthly; with backups a year comes to $748.08. Database replication and dump transfers between servers in the same region rarely come close to the 20 TB included in Europe.

Database server, answered

Can I attach extra storage for a large database?

No, block storage volumes are not sold. Each plan has a fixed local NVMe disk, so choose the plan by disk size as well as RAM; D32 has 8 vCPU, 32 GB RAM, 240 GB NVMe.

Is there a managed database service?

No. You install and run the database yourself with full root access, which also means you choose the version, extensions and settings.

Can I run a replica in another city?

Yes. Order a second server and set up PostgreSQL streaming replication or MySQL replication over TLS between their public addresses.

Should I enable swap on a database server?

A small swap file protects against sudden out-of-memory kills, but keep vm.swappiness=1 so the database is not pushed to disk. See swap and memory.

Which OS image is best for databases?

Any of them. Debian 13 and Ubuntu 24.04 ship current PostgreSQL and MariaDB; Rocky Linux 9 suits software certified for Red Hat systems.

Build it on CheapVPS

Pick the plan, a city near your users and the image, then pay the order in crypto.