Postgresql – Recommended maximum memory setting for PostgreSQL 9.4+ with Huge Pages

performancepostgresql-9.4postgresql-9.5postgresql-performance

Since PostgreSQL 9.4+ supports Linux Huge Pages, I have configured a Ubuntu 16.04 server with 16GB of RAM and 8 CPU cores to use Huge Pages with a dedicated PostgreSQL 9.5 instance.

The estimate in https://www.postgresql.org/docs/devel/static/kernel-resources.html#LINUX-HUGE-PAGES is based on VmPeak value wich is rougly a little more that the shared_buffers value.

So the question is: Since the recommended value for shared_buffers is between 25% and 40% and since PostgreSQL also relies on the operating system cache.

What is the recommended value for Huge Pages? Should I configure almost all memory to Huge Page use of PostgreSQL (12G-14G) and shared_buffers to 6G, or, which I think is more correct, configure Huge Pages with ~6.5G and shared_buffers to 6G.

Best Answer

If there are no other applications on the server potentially benefiting from huge pages, just set vm.nr_hugepages to rounded up shared buffers / pagesize. When you start PostgreSQL check its log. If it reports fall back to normal pages, increase it slightly. But I'm not sure if 16GB RAM (i.e. shared buffers 4-6GB) is enough to see the significant difference. Probably you need to set it and compare.