mani shankar
mani shankar

Reputation: 13

Why is my server very slow when I am running only one Odoo instance?

My server is configured with a 32-core processor, but whenever I run an Odoo instance, it only utilizes one core while the remaining 31 cores remain idle. This causes the server to become overloaded.

What are some effective load-balancing techniques that can be used to distribute workload across multiple cores and alleviate server overload?

Upvotes: 1

Views: 4960

Answers (1)

ChesuCR
ChesuCR

Reputation: 9670

Slowness reasons

First you need to check why Odoo is working slowly. There are several possible reasons. Some of them:

  • Odoo configuration is not set up correctly.
  • Some specific task is slow because is badly programmed. Check if some automatic task on the background is taking all the resources for instannce.
  • System resources are not enough. Normally SSD is a good idea because the transactions are going to work 10x faster

Odoo Configuration - Memory and Workers

You can set this attributes on the Odoo Configuration File:

Memory options:

--osv-memory-count-limit=OSV_MEMORY_COUNT_LIMIT
                    Force a limit on the maximum number of records kept in
                    the virtual osv_memory tables. The default is False,
                    which means no count-based limit.
--osv-memory-age-limit=OSV_MEMORY_AGE_LIMIT
                    Force a limit on the maximum age of records kept in
                    the virtual osv_memory tables. This is a decimal value
                    expressed in hours, and the default is 1 hour.
--max-cron-threads=MAX_CRON_THREADS
                    Maximum number of threads processing concurrently cron
                    jobs (default 2).

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).
                    NOTA: if this size of memory is reached, a SIGINT signal is sent to Odoo to finish the process in a correct way

--limit-memory-hard=LIMIT_MEMORY_HARD
                    Maximum allowed virtual memory per worker, when
                    reached, any memory allocation will fail (default
                    805306368 aka 768MB).
                    NOTA: if this size of memory is reached, a SIGKILL signal is sent to Odoo to finish the process in a abrupt way

--limit-request=LIMIT_REQUEST
                    Maximum number of request to be processed per worker
                    (default 8192).

Workers. Non-zero values for --workers activates Multiprocessing. Multiprocessing increases stability, makes somewhat better use of computing resources and can be better monitored and resource-restricted.

Number of Workers Calculation:

  • Rule of thumb : (#CPU * 2) + 1
  • Cron workers need CPU
  • 1 worker ~= 6 concurrent users

Although I read this on the Odoo forum or somewhere else:

I use 2 worker threads + 1 cron thread per available CPU, and 1 CPU per 10 concurent users. Make sure you tune the memory limits and cpu limits. I suggest close monitoring of the server resources (CPU, Memory, Network, etc.) in order to further tune the parameters.

Memory Size Calculation.

We consider 20% of the requests are heavy requests, while 80% are simpler ones A heavy worker, when all computed field are well designed, SQL requests are well designed, ... is estimated to consume around 1Go of RAM

A lighter worker, in the same scenario, is estimated to consume around 150MB of RAM

Needed RAM = #worker * ( (light_worker_ratio * light_worker_ram_estimation) + (heavy_worker_ratio * heavy_worker_ram_estimation) )

PostgreSQL Memory.

Set shared_buffers to 20% of the available memory, and effective_cache_size to 50% of the available memory. Change these parameters in the configuration file:

shared_buffers = 3072MB
effective_cache_size = 8192MB

It is recomended to vacuum the database from time to time

Example

If you have a VPS with 8 CPU cores and 16 GB of RAM, the number of workers should be 17 (CPU cores * 2 + 1), total limit-memory-soft value will be 640 x 17 = 10880 MB , and total limit-memory-hard 768MB x 17 = 13056 MB, so Odoo will use maximum 12.75 GB of RAM.

workers = 17
limit_memory_hard = 805306368    # total >> 13690208256
limit_memory_soft = 671088640    # total >> 11408506880
limit_request = 8192
limit_time_cpu = 60
limit_time_real = 120
max_cron_threads = 2

References

Upvotes: 2

Related Questions