This question has been flagged

Hello gurus,

I have been fighting for months with tunning up my Odoo 12 server in regards to memory consumption.

I read a lot about it and made lots of tests without success.

My problem is, memory consumption is always increasing and never drops even if no one is using Odoo.

I am sure it is related to Odoo, because if I restart the service, memory is freed drastically.

Usually it begins at about 4%-5% and starts increasing (10, 15, 20… 50, 80…) as users starts using Odoo.

As per the CPU it is great. Sometimes it goes over 50% (on higher loads) but usually it is below 15% and I can see its consumption is being recicled/cleaned.

My Server
UBUNTU 18.04 – 4CPU / 8GB RAM
ODOO 12

odoo-server.conf


limit_memory_hard = 2684354560
limit_memory_soft = 2147483648
limit_request = 8192
limit_time_cpu = 300
limit_time_real = 600
limit_time_real_cron = -1
max_cron_threads = 2
workers=8

Tried to manage by changing “limit_memory_hard” and “limit_memory_soft” and use lower values but if the values are too low it raises an error:

"LongPolling Virtual memory limit reached"

What could be the problem and what are the advisable settings for this server specs?

Thank you very much
Avatar
Discard
Best Answer

Lets recheck your memory handling calculations:

RAM: 8GB

Core: 4

So workers = (core * 2) + 1 = (4*2)+1(Cron Worker)

workers = 8+1=9

limit_memory_soft = 640 * 9 * 1024 * 1024 = 6039797760

limit_memory_hard = 768*9*1024*1024 = 7247757312

so your odoo conf must contain following calculations

limit_memory_soft = 6039797760
limit_memory_hard = 7247757312
workers = 9

Deatils:

  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).



Avatar
Discard
Author

Hi Hillar,
Thank you very much for taking your time.
I will try with settings you sent me and keep you updated.
I thought increasing “memory limits” would make the system “recycle memory” later and I need it to be as fast as possible in order to release it.
I will keep you updated
Thank you once again

Author

@Hillar,

The week has started and now I will be able to track the settings more easily because I will have several users using the system.

For now I'm using the settings you sent me and just decided to reduce the "db_maxconn" a bit to 10 (before it was 15).

So far everything seems to be working fine, but I will continue to follow.

Thanks again and I will keep you updated.

Author

@Hillar
Thank you very much once again.

Two days and RAM is still below 50%.

Sometimes it goes over 60% but as expected, most of the time it’s below 50%.

Thank you very much

It will be auto generated after starting odoo with config creation. Python odoo-bin -s

I noticed that in the limit_memory_soft examply you multiplied by the number of workers 9. But this is not correct, the limit_memoy_soft and limit_memory_hard are per workers, thus you should not multiple by that, just 1024 * 1024 * SIZE_IN_MB