Odoo is the most popular ERP software (Enterprise Resource Planning) written in Python and uses PostgreSQL as its back-end database. Community Edition Odoo is free and open source, which includes project management, manufacturing, accounting, invoicing and sales, warehouse management, human resources, and more. There are about 30 main modules and over 3000 additional modules. Odoo is complex software, and deploying a number of modules that have a large amount of data inside a database, etc. may cause performance degradation. Odoo’s two main bottlenecks are disk access and database query times. To improve the performance of your Odoo instance, make sure to use:
- Fast storage drives (preferably SSD)
- Linux VPS with lots of RAM.
- Enabling multiprocessing mode in Odoo.
- Configure and optimize PostgreSQL service correctly.
SSD VPS with lots of RAM
As we mentioned earlier, random disk access speed is one of the main bottlenecks for Odoo, so make sure to host an SSD based Odoo VPS. Always install Odoo on a VPS with a lot of RAM, as Odoo is known to be resource intensive, and load your entire Odoo instance and your database into RAM if possible. SSDs excel especially in random access and can achieve random access IOPS hundreds of times higher than conventional mechanical disk drives because SSDs have no moving parts. No matter how much optimization and configuration you do on your Odoo, if the server is not fast or running on an SSD, your Odoo will be slow. The right hosting for your Odoo is the most important factor in the performance of your Odoo.
Other Odoo optimizations include:
Enable MultiProcessing option in Odoo config
To do this, find the OpenERP-server binary:
#updatedb #locate openerp-server /usr/bin/openerp-server
Run the following command:
The output of this command should be like this:
Usage: openerp-server [options] Options: --version show program's version number and exit (...) Multiprocessing options: --workers=WORKERS Specify the number of workers, 0 disable prefork mode. --limit-memory-soft=LIMIT_MEMORY_SOFT Maximum allowed virtual memory per worker, when reached the worker be reset after the current request (default 671088640 aka 640MB). --limit-memory-hard=LIMIT_MEMORY_HARD Maximum allowed virtual memory per worker, when reached, any memory allocation will fail (default 805306368 aka 768MB). --limit-time-cpu=LIMIT_TIME_CPU Maximum allowed CPU time per request (default 60). --limit-time-real=LIMIT_TIME_REAL Maximum allowed Real time per request (default 120). --limit-request=LIMIT_REQUEST Maximum number of request to be processed per worker (default 8192).
The number of worker processes must be equal to the number of processor cores allocated to the VPS, or if you want to leave some processor cores exclusively for PostgreSQL database, cron jobs or other applications installed on the same VPS where the Odoo instance is installed and running, install the number of workers to a lower value than the processor cores available on the VPS to avoid resource depletion.
limit-memory-soft, limit-memory-hard and self-explanatory, you should leave them at their default values or change them depending on the RAM available on the actual VPS.
For example, if you have a VPS with 8 CPU cores and 16 GB of RAM, the number of workers should be 17 (processor cores * 2 + 1), the total limit-memory-soft value will be 640 x 17 = 10880 MB, and the total limit- memory-hard 768MB x 17 = 13056 MB, so Odoo will use a maximum of 12.75 GB of RAM.
For example, on a VPS with 16 GB of RAM and 8 processor cores, edit the Odoo configuration file (e.g. /etc/odoo-server.conf) and add the following lines to it:
workers = 17 limit_memory_hard = 805306368 limit_memory_soft = 671088640 limit_request = 8192 limit_time_cpu = 60 limit_time_real = 120 max_cron_threads = 2
Remember to restart Odoo for the changes to take effect.
Configure and optimize PostgreSQL correctly
As far as optimizing PostgreSQL, it is a good idea to update to the latest PostgreSQL version whenever a new version is released. There are two parameters in the PostgreSQL configuration file (pg_hba.conf) that need to be changed: shared_buffers and effective_cache_size. Set shared_buffers to 20% of available memory, and effective_cache_size to 50% of available memory.
For example, if Odoo is installed on an SSD VPS with 16 GB of RAM, use the following parameters in the pg_hba.conf file:
shared_buffers = 3072MB effective_cache_size = 8192MB
Restart the PostgreSQL service for the changes to take effect.
Also, don’t forget to manually run ”VACUUM” periodically. ‘Vacuuming’ cleans up stale or temporary data, but please be aware that this is CPU and disk-heavy.