Knowledgebase

Question About Servers

How to Optimize an Odoo Server Print

  • 6

In this guide, we will show you how to optimize your server for the best Odoo performance.

Server Resources

Set Worker and Memory Limits for Odoo

Open the configuration file of your Odoo instance: 

nano /etc/odoo-live.conf

Note: change odoo-live to the relevant Odoo instance name.

 

Set (or change) the following fields:

  • workers - the number of workers. Should equal to (CPU CORES * 2) + 1 (e.g. 13 workers for 6-core CPU). If you want to give some CPU resources to other processes (like the database), set the value lower.
  • limit_memory_hard - the maximum allowed RAM for a worker.
  • limit_memory_soft - the minimum amount of RAM for a worker.

When setting the memory limits, take other applications into account as well. The combined formula should be: (TOTAL RAM - RAM FOR OTHER APPS) / WORKER COUNT

 

For example, for a system with 6 CPU cores and 16GB of RAM, the settings would be as follows (not accounting for other processes):

workers = 13

limit_memory_hard = 1208MB

limit_memory_soft = 1024MB

 Note: it is advised to allocate 20% of RAM for PostgreSQL (see below). Take that into account when doing your calculations. This setting does not work with all servers, if it causes downtime for your server please revert.

 

Restart Odoo: 

sudo service odoo-live restart

Note: change odoo-live to the relevant Odoo instance name.

 

PostgreSQL Database 

Optimize Buffer and Cache Size

Open the configuration file of your PostgreSQL installation: 

/var/lib/postgresql/data/postgresql.conf

Note: the directory name inside the /var/lib/ directory might vary depending on your system.

 

Set (or change) the following fields:

  • shared_buffers - the amount of RAM for PostgreSQL to use (writing data will be faster). Should equal to (TOTAL RAM * 0.2).
  • effective_cache_size - the amount of DISK SPACE for PostgreSQL cache (i.e. temporary data). Should equal to (TOTAL RAM * 0.5).

 

For example, for a system with 16GB of RAM, the settings would be as follows:

shared_buffers = 3072MB

effective_cache_size = 8192MB

 

Restart PostgreSQL: 

sudo service postgresql restart

 

Log Time-intensive SQL Statements

You can see which statements take long to execute and then optimize them. Here's the example for logging any statement that takes more than 2 seconds.

 

In the PostgreSQL configuration file (see above), set the following settings:

log_statement = none

log_min_duration_statement = 2000

Note: you can change 2000 to any number of milliseconds. 

 

Restart PostgreSQL: 

sudo service postgresql restart

 

Clean the Tables

You can use the VACUUM command to clean the outdated data (like temporary key-value pairs) that is still stored in the database for a given table.

Do note that using VACUUM is a resource-intensive process, so it is advised to run it manually. 

 

Assuming you are logged in as your Odoo user, enter the PostgreSQL shell:

psql

 

Connect to your Odoo database:

\c odoo-live

Note: change odoo-live to the relevant database name. 

 

List all the tables:

\dt

 

Use VACUUM to clean temporary data for a selected table.

VACUUM table_name;

Note: change table_name to the name of the table that you want to clean.

 

Restart PostgreSQL: 

sudo service postgresql restart

 

 

 


Was this answer helpful?

« Back

Enterprise-Grade Hardware

  • Samsung
  • Juniper
  • Western Digital
  • Supermicro
  • LSI
  • Intel
  • R1Soft Backups
  • cPanel
  • MySQL
  • Parallels
  • HP Partner