PostgreSQL on dedicated servers

PostgreSQL rewards hardware it does not share: memory for caches, NVMe for the write-ahead log and cores for parallel queries. Here is how to set it up and size it on a rented machine.

Which version should I run?

A current major release from the project's own repository, which publishes packages for Debian, Ubuntu and the EL family and keeps several majors available side by side. Each major release is supported for five years, and new ones arrive every autumn; PostgreSQL 18 added asynchronous I/O for reads, which helps scans on fast drives.

apt install -y postgresql-common
/usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y
apt install -y postgresql-18
pg_lsclusters

Which memory settings come first?

SettingStarting pointWhy
shared_buffers25 percent of memoryPostgreSQL's own page cache
effective_cache_size70 to 75 percent of memoryTells the planner how much the OS caches
work_mem16 to 64 MBPer sort or hash, per query node, so keep it modest
maintenance_work_mem1 to 4 GBFaster index builds and vacuum
huge_pagestry, with pages reservedLower overhead for large shared memory

On a 128 GB machine that means 32 GB of shared buffers and an effective cache size near 96 GB. Raise work_mem per role for reporting users instead of globally.

What changes on NVMe drives?

The planner's assumptions. Its defaults date from spinning disks, where random reads cost four times a sequential one. On NVMe, set random_page_cost to 1.1 so index scans are chosen when they should be, and raise effective_io_concurrency so prefetching keeps the drive busy. Increase max_wal_size to 8 to 16 GB so checkpoints happen on time rather than being forced by WAL volume.

ALTER SYSTEM SET random_page_cost = 1.1;
ALTER SYSTEM SET effective_io_concurrency = 200;
ALTER SYSTEM SET max_wal_size = '16GB';
ALTER SYSTEM SET checkpoint_completion_target = 0.9;
SELECT pg_reload_conf();

How do I add a streaming replica?

Create a replication role, allow it in pg_hba.conf, then clone the primary with pg_basebackup. Replicas serve read-only queries and stand ready for failover. Between our servers, replication runs over the public port, so require TLS for the replication connection or carry it over a WireGuard tunnel.

pg_basebackup -h 10.30.0.1 -U replicator -D /var/lib/postgresql/18/main -X stream -R -C -S replica_waw -P

The -R flag writes the standby settings, and -C -S creates a replication slot so the primary keeps WAL until the replica has it.

How should backups work?

With a tool that combines full, differential and incremental backups with continuous WAL archiving, such as pgBackRest. It restores to any point in time, verifies checksums and compresses in parallel. Store the repository on another machine, ideally a Storage model in a second data centre, and rehearse a restore every month. Logical dumps with pg_dump remain useful for single databases and version upgrades; Ship database dumps to a second server covers that route.

How do I handle failover?

With an orchestrator such as Patroni, which uses a consensus store like etcd to elect a leader, promote a replica when the primary fails and rewire the others. Three small etcd members plus two or three database nodes is the usual layout. Applications connect through a proxy or a DNS name that follows the leader. Keep the database nodes in one or two nearby data centres so synchronous commits, if used, stay fast.

Which machine fits?

Size memory for the hot data set, NVMe for the total size with headroom, and cores for concurrent queries.

DatabaseMachineMemory and drives
Up to 200 GB, moderate loadESSENTIAL-464 GB DDR4, 2x 960 GB SSD NVMe, Soft RAID
Up to 600 GB, busy applicationBUSINESS-5 2026128 GB DDR5, 2x 960 GB SSD NVMe, Soft RAID
Up to 1.2 TB, analytics and OLTPENTERPRISE-a3 2026128 GB DDR5, 2x 1.92 TB SSD NVMe

ESSENTIAL-4 gives 16 EPYC cores with ECC memory for $106.20 a month. If a database ever refuses to start, Rescue a database from a dead system walks through recovery from rescue mode, and Database servers compares engines.

Machines for PostgreSQL

Lowest monthly price of each model across its data centres; the model page shows the price in every location.

ModelProcessorCoresMemoryDrivesPortPer month
ESSENTIAL-4AMD EPYC 73131664 GB2x 960 GB SSD NVMe1 Gbps unmetered$106.20
ESSENTIAL-5AMD EPYC 741324128 GB2x 960 GB SSD NVMe1 Gbps unmetered$120.00
ESSENTIAL-XLAMD EPYC TURIN 945548128 GB2x 1.92 TB SSD NVMe1 Gbps unmetered$212.40
BUSINESS-5 2024AMD EPYC 8224P2496 GB2x 960 GB SSD NVMe3 Gbps unmetered$280.20
BUSINESS-5 2026INTEL Xeon 6527P24128 GB2x 960 GB SSD NVMe3 Gbps unmetered$406.20
ENTERPRISE-a3 2026AMD EPYC TURIN 935532128 GB2x 1.92 TB SSD NVMe5 Gbps unmetered$481.80

Size memory for the hot data, NVMe for the whole database, cores for concurrency.

See all servers and prices

Related pages

Database servers

NVMe machines with large memory for PostgreSQL, MySQL, MariaDB and MongoDB, from a single primary to replicated pairs.

Read more

etcd clusters

Run etcd on bare metal: three or five members, client and peer ports, fsync latency on NVMe, quota and compaction, snapshots and TLS everywhere.

Read more

Rescue a database from a dead system

Get a consistent MariaDB, MySQL or PostgreSQL dump out of a server whose operating system no longer starts, working entirely from rescue mode.

Read more

Ship database dumps to a second server

Schedule compressed, encrypted MariaDB or PostgreSQL dumps and send them to a Storage machine elsewhere, with retention and restore tests.

Read more

Questions and answers

How much memory should shared_buffers use?

About 25 percent of system memory is a good start, with effective_cache_size set to 70 to 75 percent.

What random_page_cost should PostgreSQL use on NVMe?

About 1.1, so the planner treats random reads as nearly as cheap as sequential ones and chooses index scans appropriately.

How do I create a PostgreSQL replica?

Clone the primary with pg_basebackup using -R and a replication slot, then start the replica; protect the connection with TLS or WireGuard.

What is a good way to back up PostgreSQL with point-in-time recovery?

A tool such as pgBackRest for full, incremental and point-in-time recovery, storing its repository on another machine.

How does automatic PostgreSQL failover work?

An orchestrator like Patroni uses a consensus store such as etcd to elect a leader and promote a replica when the primary fails.