Odoo postgreSQL on a VM

Although the official position is to avoid installing Odoo on a VM, I found out over the years that PostgreSQL had improved a whole lot since version 9.2 and it was not foolish to consider a VM under Vsphere as a potential candidate for a production environment.

Odoo & postgreSQL inside a VM

vPostgres 9.2 inherits all the performance improvements made in PostgreSQL 9.2 from upstream and features good out-of-box performance in most situations. vSphere is known for great out-of-box performance for common enterprise workloads. As a result, we refer to the performance best practices for vSphere and PostgreSQL for general performance tuning efforts. We point out what are most relevant to database workloads below:

  • Configure the VM to use the VMXNET3 NIC driver.
  • Configure the VM to use the PVSCSI disk driver and use thick and eager-zero virtual disk formats.
  • When using Linux as a guest operating system, use the noop disk scheduler for guest disks.

We recommend the following performance best practices specifically for vPostgres on vSphere:

  • Dedicate a VM and a vPostgres server to any database of nontrivial performance concern.
  • Put the vPostgres database cluster’s DATA and WAL directories each on a dedicated virtual disk (VMDK) file and separate them from other entities such as operating system code and data.
  • Test your application by experimentally sizing vPostgres server shared buffers beyond the conventional recommendation to seek the best performance out of fixed VM memory resources and use the highest load levels anticipated for your database application to conduct such tests.
  • Avoid sizing vPostgres shared buffers of around 50% of VM memory. For example, size vPostgres shared buffers outside the region of 45-55% of VM memory.
  • Enabling the vPostgres database balloon is recommended when (even occasional) memory overcommitment is anticipated, particularly if you size shared buffers unconventionally large relative to VM memory size. To use this feature, add the following line to the postgresql.conf of vPostgres server instance and then reload postgresql.conf.
  • enable_pgballoon = on
  • Always enable the guest kernel-level balloon driver.