Layer 3 · self-hosting reality check
What it actually takes to self-host PostgreSQL
The docs say 256 MB. In practice you want 4 GB for a real application database. Here is the honest version — real requirements, real monthly cost, what you will be maintaining, and the one thing that catches people out.
Usually reached from MongoDB Atlas alternatives, where PostgreSQL is one of the picks.
| RAM — documented minimum | 256 MB |
|---|---|
| RAM — what it really needs | 4 GB for a real application database |
| CPU | 2 vCPU |
| Disk | Data × 2. WAL, indexes and bloat all want room, and autovacuum needs slack to work. |
| Monthly cost | $24–48/mo for a 4–8 GB instance, against managed Postgres at 2–3× that for equivalent specs |
| Setup time | 1 hour to run, a day to configure properly |
| How you install it | distribution package or container; the official Docker image is fine for a single node |
| Ongoing maintenance | Real and non-negotiable: backups you have actually restored, major-version upgrades roughly annually, and index maintenance as the data grows. |
| Where it stops scaling | A single well-tuned node handles far more than people expect — hundreds of gigabytes and thousands of transactions per second. Read replicas come before sharding, always. |
The thing that catches people out
The default configuration is deliberately tiny — shared_buffers ships at 128 MB regardless of how much RAM the machine has, so Postgres will happily ignore 90% of your server. Run your numbers through a tuning calculator and set shared_buffers, work_mem and effective_cache_size before you benchmark anything. Most people who conclude 'Postgres is slow' never left the defaults.
When not to self-host PostgreSQL
Nobody on the team is willing to own backups and prove a restore. Managed Postgres is expensive precisely because point-in-time recovery is genuinely hard, and a database you cannot restore is not a database.
Every guide here carries this section. A site that only ever tells you to self-host is selling something — the useful answer is sometimes no.
Other Layer 3 self-hosting guides
Common questions
- How much RAM does PostgreSQL actually need?
- 4 GB for a real application database in practice. The documented minimum is 256 MB, which is the figure at which the process starts rather than the figure at which it works under real use. 2 vCPU alongside it.
- What does self-hosting PostgreSQL cost per month?
- $24–48/mo for a 4–8 GB instance, against managed Postgres at 2–3× that for equivalent specs This is commodity VPS pricing and excludes your time, which is the larger cost for most people — budget for real and non-negotiable: backups you have actually restored, major-version upgrades roughly annually, and index maintenance as the data grows.
- How long does it take to set up PostgreSQL?
- 1 hour to run, a day to configure properly, via distribution package or container; the official Docker image is fine for a single node.
- When should I NOT self-host PostgreSQL?
- Nobody on the team is willing to own backups and prove a restore. Managed Postgres is expensive precisely because point-in-time recovery is genuinely hard, and a database you cannot restore is not a database.
- What is the most common mistake when self-hosting PostgreSQL?
- The default configuration is deliberately tiny — shared_buffers ships at 128 MB regardless of how much RAM the machine has, so Postgres will happily ignore 90% of your server. Run your numbers through a tuning calculator and set shared_buffers, work_mem and effective_cache_size before you benchmark anything. Most people who conclude 'Postgres is slow' never left the defaults.