What makes a database fast
A database reads far faster from memory than from disk. It therefore keeps a cache, and the size of that cache matters more than anything else:
- MariaDB and MySQL (InnoDB engine): the cache is called the buffer pool, set by
innodb_buffer_pool_size. The MariaDB documentation advises that it should hold most of the server's active data.
- PostgreSQL: the
shared_buffers setting. On a server dedicated to the database with at least 1 GB of memory, the PostgreSQL documentation suggests 25% of memory as a starting point, and considers it unlikely that going beyond 40% will do better, because PostgreSQL also relies on the operating system's cache.
Whatever does not fit in memory is read from disk: NVMe drives then cut the wait. And the ECC memory of the Xeon machines corrects single-bit errors before they reach your data. On a dedicated server, none of this is shared with another customer.
Choosing the machine
- Ryzen 9 9950X: 16 fast cores, 64, 96 or 128 GB of DDR5 and 2 TB of NVMe included. For a heavily used database with many short queries.
- Ryzen 7 7700: 8 cores, 32 or 64 GB of DDR5, 2 TB of NVMe. For a medium-sized database behind a website, a shop or an API.
- 2x Xeon E5-2650 v3: 64 to 512 GB of DDR4 ECC and NVMe. For a large database that must fit in memory, or several databases on the same machine.
- 2x Xeon Gold 6254: 256 GB of ECC memory and iDRAC access, subject to availability.
RAID is available, to be specified when ordering or by ticket: a mirror keeps the database online if a drive fails, but protects against neither deletion nor corruption. For more space, add NVMe at +€15 per TB per month, or SSD at +€10 per TB per month. The Ryzen machines are on our AS218808 network, the Intel machines with a partner provider in France; all have a 1 Gb/s port. The guide Ryzen or Xeon helps you decide, and today's prices are on the dedicated servers page.
Securing, backing up, replicating
Do not expose the database port to the Internet. MariaDB listens on port 3306, PostgreSQL on 5432. By default, PostgreSQL listens only on localhost, and many MariaDB packages bind to 127.0.0.1. Check which address the database listens on:
ss -tlnp | grep -E '3306|5432'
If the application runs on another machine, open the port to its address only in the firewall, or go through a private tunnel. The rest of the method is in securing a dedicated server.
Back up every day, off the server. A logical export is done with mariadb-dump or pg_dump; for a large InnoDB database, mariadb-backup takes a hot copy. PostgreSQL also offers continuous archiving of its logs, to go back to a precise point in time.
mariadb-dump --single-transaction --all-databases | gzip > backup-$(date +%F).sql.gz
sudo -u postgres pg_dump -Fc appdb > appdb.dump
Test a restore from time to time. Replication (MariaDB replicas through the binary log, streaming replication to a standby server with PostgreSQL) keeps a second up-to-date copy on another machine, but does not replace backups: a dropped table is dropped on the replica too.
When a VPS is enough
- Your database is small and fits in a few gigabytes of memory: a Ryzen VPS runs it easily, next to the application.
- You are starting a project: a VPS is ready in a few minutes, and you can move the database to a dedicated server once it grows. The guide migrating to a dedicated server explains how.
- You do not want to administer anything: on a dedicated server, the system, updates, the firewall and backups are your responsibility.
A dedicated server becomes worthwhile when the active data no longer fits in a VPS's memory, when the load is heavy and continuous, or when you need ECC memory or RAID. To compare, read one dedicated server or several VPS.