Best AWS EC2 Instance for PostgreSQL
For self-hosted PostgreSQL, **r6i.large** at $0.1260/hr (~$91/mo) is a sensible starting point. The reason isn't the CPU count — it's the 1:8 vCPU-to-memory ratio. Postgres performance is dominated by buffer cache hit rate, and an r-series memory-optimized instance gives you 16GB of RAM on the smallest size versus 8GB on the equivalent m-series, with similar pricing per GB.
That said: before going further, consider whether you should be self-hosting Postgres at all. RDS Postgres on a comparably-sized db.r6i.large costs more per hour but eliminates the operational overhead of managed backups, automatic failover to a standby, point-in-time recovery, and minor version upgrades. The "self-host on EC2 for cost savings" math rarely accounts for the engineer-hours those features replace. If you have a specific reason to self-host (extension that RDS doesn't support, custom replication setup, sub-1-second failover requirements), proceed; otherwise, RDS.
If you do self-host: never put the database files on instance-store local SSD. They're fast, but they're ephemeral — when the instance stops, the data is gone. Provision a separate gp3 or io2 EBS volume sized 2-3× your current dataset and mount it at /var/lib/postgresql/data. The IOPS limits on gp3 are generous enough for most workloads; only step up to io2 if you've measured sustained >3000 IOPS in production.
For OLTP workloads with heavy concurrent writes, the "scale" tier (r7iz.xlarge) gives you both more RAM and higher single-thread clock speed than the standard tier — Postgres benefits meaningfully from clock speed on per-transaction overhead like WAL writes and lock acquisition. Pair with PgBouncer running on the same instance to handle connection multiplexing — that's the one piece of database-adjacent infrastructure that's fine to colocate.
Alternatives by tier
Things to consider
- For self-hosted Postgres, prefer RDS unless you have a specific reason to manage your own — backup, replication, and failover are real work
- If you do self-host, r-series (memory-optimized) wins over m-series for almost every Postgres workload — buffer cache matters
- Add a separately-provisioned io2 or gp3 EBS volume for /var/lib/postgresql/data — never use instance-store local SSD for a primary DB
- Connection pooling (PgBouncer) on the same instance is fine; running the application server on the same instance is not