PostgreSQL Resource Management – Optimize Memory Usage

memorypostgresqlpostgresql-9.3

I'm consolidating multiple Linux boxes running Postgres into one box.

Given the way Postgres handles resource utilization, would one single server service handling all the databases provide a much better performance than multiple server services (each one listening to different IP:port) running on the same host?

Thanks

Best Answer

In general, a single instance is more efficient, but has inferior performance isolation between databases.

If you want maximum throughput and best resource utilisation, put them all in a single instance. One busy DB will be able to affect other DBs more easily this way, especially when it comes to things like high rates of small write transactions. Features like async commit, commit delay, etc, help. If you group them all on one instance you'll also have to do any physical backups and streaming replication / PITR for the whole set of DBs, you can't isolate just one DB.

If you want to reduce the impact one busy/overloaded DB has on another DB, isolate them into their own instances and put each on a separate file system, perferably on separate underlying storage. You'll pay a price in wasted shared_buffers space, extra fsync()s, etc, and you'll find things like user management a major pain, but you'll be able to do streaming replication / physical backups of just one DB and you'll be more able to manage their relative resource allocations. If they're separate instances you can use things like nice, ionice, etc more effectively and can manage storage quotas somewhat better.