Setting up a production environment for Odoo requires consideration of hardware and software configuration to ensure optimal performance, reliability, and scalability.
System Specifications:
- CPU(s): 24
- Vendor ID: GenuineIntel
- Model name: Intel(R) Xeon(R) Silver 4310 CPU @ 2.10GHz
- CPU family: 6
- Model: 106
- Thread(s) per core: 2
- Core(s) per socket: 12
- Socket(s): 1
- Stepping: 6
Memory and Storage:
- RAM: 32 GB
- SSD: 1000 GB
Postgres docker compose:
services:
postgres_db:
image: postgres:16
container_name: postgres_db
environment:
- POSTGRES_DB=postgres
- POSTGRES_USER=odoo
- POSTGRES_PASSWORD=syour_password
ports:
- "5539:5432"
volumes:
- ./data:/var/lib/postgresql/data
restart: unless-stopped
networks:
- internal_shared_net
shm_size: '9g'
networks:
internal_shared_net:
external: true
Note: shm_size: '9g' . avoid error Cannot resize shared memory segment in Postgres
Odoo Configuration (odoo.conf
):
limit_memory_soft = 2147483648 ; 2.0 GB
limit_memory_hard = 2684354560 ; 2.5 GB
limit_time_cpu = 900 ; 15 minutes CPU time per request
limit_time_real = 1800 ; 30 minutes wall-clock time per request
workers = 10 ; Number of worker processes
max_cron_threads = 2 ; Number of threads for cron jobs
db_maxconn = 200 ; Maximum database connections
proxy = True ; Enable reverse proxy support
limit_request = 8192 ; Maximum request size (8 MB)
Note:
- workers = 10 → Each worker uses 2.5 GB of RAM, so the total RAM used by workers will be 10 x 2.5 GB = 25 GB.
PostgreSQL Configuration (postgresql.conf
):
max_connections = 200
shared_buffers = 8GB
effective_cache_size = 24GB
maintenance_work_mem = 2GB
checkpoint_completion_target = 0.9
wal_buffers = 16MB
default_statistics_target = 100
random_page_cost = 1.1
effective_io_concurrency = 200
work_mem = 10485kB
huge_pages = try
min_wal_size = 1GB
max_wal_size = 4GB
max_worker_processes = 24
max_parallel_workers_per_gather = 4
max_parallel_workers = 24
max_parallel_maintenance_workers = 4
log_min_duration_statement = 500 # Query log running more than 500ms
log_statement = 'none' # Minimize log generation
#------------------------------------------------------------------------------
# AUTOVACUUM
#------------------------------------------------------------------------------
autovacuum = on # Automatic Vacuum Activation
autovacuum_max_workers = 4 # Number of Autovacuum operators to run in parallel
autovacuum_vacuum_cost_limit = 2000
autovacuum_vacuum_scale_factor = 0.1
autovacuum_analyze_scale_factor = 0.05
Total Memory Allocation:
-
PostgreSQL:
- Shared Buffers = 8 GB
-
Odoo Workers:
- Workers = 10 (10 x 2.5 GB = 25 GB)
-
Linux System:
- RAM = 4GB
-
Total Odoo Workers + PostgreSQL Memory + Linux System = 38 GB = 120% RAM. Configuration usage = 120% of RAM.
Depending on the actual situation, if you have plenty of available RAM, you can increase the memory allocated to the workers.
If you notice that the RAM is insufficient, you may need to upgrade your RAM.
Config nginx
server {
listen 80;
server_name 192.168.1.10; IP local server odoo
access_log /var/log/nginx/odoo_access.log;
error_log /var/log/nginx/odoo_error.log;
keepalive_timeout 65;
proxy_read_timeout 720s;
proxy_connect_timeout 720s;
proxy_send_timeout 720s;
client_max_body_size 200m;
location / {
proxy_pass http://127.0.0.1:8869;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /longpolling/ {
proxy_pass http://127.0.0.1:8072;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location ~* \.(jpg|jpeg|png|gif|ico|css|js|woff|woff2|ttf|svg)$ {
try_files $uri @odoo;
expires 1d;
access_log off;
add_header Cache-Control "public";
}
location @odoo {
proxy_pass http://127.0.0.1:8869;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript;
gzip on;
}
Final:
The configuration is for a production Odoo environment with a medium-to-high workload. It balances the number of workers with the available RAM, and optimizes PostgreSQL for performance.
Reply