Running Odoo on default settings is like driving a supercar in first gear. You might have a powerful server, but without a properly tuned odoo.conf, you will inevitably face 504 Gateway Timeouts, sluggish performance, or the dreaded "Out of Memory" crashes.
The secret to a high-performance Odoo instance lies in three parameters: workers, limit_memory_soft, and limit_memory_hard. In this post, we will move past guesswork and use mathematics to calculate the perfect configuration for your hardware.
1. The Multi-Processing Model: Understanding Workers
By default, Odoo runs in multithreading mode (workers = 0). However, for production environments, you must switch to multi-processing mode. Each "worker" is a dedicated Python process that handles incoming user requests.
The Golden Rule for Calculation:
The standard formula provided by the Odoo community is:
- Formula: (CPU_Cores * 2) + 1
- Example: If your VPS has 4 CPU Cores, your calculation is: (4 * 2) + 1 = 9 Workers
Pro Tip: Never exceed the number of workers your RAM can support, even if you have many CPU cores. RAM is usually the bottleneck before the CPU.
2. The RAM Formula: Soft vs. Hard Limits
This is where most administrators fail. If you set these limits too low, Odoo kills processes before they finish; too high, and your server crashes. We assume a standard Odoo worker consumes roughly 150MB for light tasks and up to 256MB for heavy tasks (like report generation).
A. limit_memory_soft
This is the threshold where Odoo starts to reset the worker after a request is finished to prevent memory leaks.
- Formula: Total_Workers * 128MB (in bytes)
- Calculation (for 9 workers): 9 * 128 * 1024 * 1024 = 1,207,959,552
B. limit_memory_hard
This is the "kill switch." If a worker hits this limit, the OS terminates it immediately to protect the server.
- Formula: Total_Workers * 256MB (in bytes)
- Calculation (for 9 workers): 9 * 256 * 1024 * 1024 = 2,415,919,104
3. Strategic Scenario: 8GB RAM & 4 Core CPU
Let's look at a real-world server setup. Why shouldn't we give all 8GB to Odoo? Because PostgreSQL needs breathing room to cache your data.
- Odoo Workers (9): Uses approx 2.3GB of RAM.
- PostgreSQL & OS: Needs at least 2GB - 3GB to run smoothly.
- Buffer: The remaining RAM acts as a safety net for peak traffic.
4. Technical Implementation: The odoo.conf Snippet
Based on our 4 Core / 8GB RAM calculation, here is your optimized configuration:
Ini, TOML
[options]
; --- Performance Tuning ---
; Enabling multi-processing mode
workers = 9
; 9 workers * 128MB = 1.15GB (approx)
limit_memory_soft = 1153433600
; 9 workers * 256MB = 2.30GB (approx)
limit_memory_hard = 2306867200
; Allow long-running reports/imports
limit_time_cpu = 600
limit_time_real = 1200
; Maximum number of cron threads (background tasks)
max_cron_threads = 2
; Number of requests a worker will process before recycling
limit_request = 8192
Conclusion: Achieving System Stability
Optimizing your odoo.conf is not a "set it and forget it" task, but rather a vital part of maintaining a healthy ERP ecosystem. By using the mathematical approach to calculate workers and memory limits, you move away from trial-and-error and toward a data-driven infrastructure.
Key Takeaways:
- Balance is Key: Never allocate 100% of your RAM to Odoo workers; always leave at least 20-30% for PostgreSQL and the OS kernel.
- Monitor and Adjust: Use tools like htop or pg_activity during peak hours. If you see frequent "Worker killed" messages in your logs, it’s a sign that your limits are too tight or there is a memory leak.
- Scale Vertically First: Ensure your single-server configuration is mathematically sound before moving to multi-server load balancing.
By mastering these parameters, you ensure that your Odoo instance remains fast, responsive, and—most importantly—stable under heavy business loads.
