Performance
Tips &
Tricks
Olivier Dony
@odony
1 Deploying
Deployment Architecture
Rules of thumb
+ Enforce limits
+ Recycle processes
Activate multi-worker to use your fancy hardware! + Perform better
+ Sync changes
How many workers processes? 1 per CPU core, x2 for recycling
Min = 6 (typical browser keepalive pool size)
Dedicated RAM RAM = 24GB = 24 workers
Max = e.g.
Worker soft memory limit Soft limit = 1GB
How many requests/second? ~ 6-7 x Workers e.g. 24 workers = 160 r/s
How many users? ~ 5-10 per Worker e.g. 24 active workers = 180 users
Deployment Architecture
Scaling: example 1 Backend
+
Frontend
Odoo Server
n
Workers: 20
o
at
p lic
re
100 users 16c/32t
Xeon E5 2640v3 –
10000 visitors/day 2.6GHz
Odoo Server (B) 64 GB RAM
Workers: 20
Deployment Architecture
Scaling: example 2
Frontend Backend
Odoo
Workers:10 NFS
DB + File
Load
Balancer Odoo
NFS Server
Workers:10
NFS
300 users 6c/12t
Xeon E5 1650v3 –
25000 visitors/day Odoo 3.5GHz
Workers:10 64 GB RAM
4c/8t
3X Xeon E5 1630v3 - + replicaton of backend
3.7GHz
32 GB RAM
Deployment Architecture
Recommendations
+ SSL Termination
Setup a reverse proxy in front of Odoo + Gzip
+ Serve static assets
+ Load balancing
+ Block access to DB manager
Backend (DB): max I/O, RAM and Speed 64GB + SSD + 3.5GHz Base CPU speed
Frontend (HTTP): max Speed and # Cores 6c/12t 3.5GHz Base CPU speed
2 Measuring &
Monitoring
Watch your deployment’s
performance
PostgreSQL: transactions / minute
Odoo: requests / minute, avg duration
Disk: response time, IOPS
System: load, I/O wait, memory
Network: connections, bandwidth
Establish your
performance baseline
Watch your deployment’s Suggested tool: Munin
performance
PostgreSQL: transactions / minute day week
Odoo: requests / minute, avg duration
Disk: response time, IOPS month year
System: load, I/O wait, memory
Built-in plugins for most key metrics
Network: connections, bandwidth Writing plugins is trivial
Constant storage footprint (rrdtool)
Configurable limits/warnings
Establish your Example plugins
performance baseline Nginx times: https://git.io/vP3Sj
Odoo times: https://git.io/vP3h9
3 Optimizing
Update
your deployment
regularly
Optimizing your Deployment
PostgreSQL
Verify the usual server settings: effective_cache_size, work_mem, shared_buffers
See also documentation: https://wiki.postgresql.org/wiki/Performance_Optimization
Log slow queries: log_min_statement_duration = 500
Then watch slow queries in PostgreSQL log file
Use EXPLAIN ANALYZE <query> to verify the plan See also https://explain.depesz.com
Verify statistics and vacuuming (autovacuum!)
Create missing indexes carefully (composite, order, etc.)
Create missing FK indexes to fix slow deletion
Sample the system while running
PostgreSQL
Install pg_activity to watch the database
+ htop-like for PostgreSQL
+ Running/Waiting/Blocking queries
+ Read/Write per second
+ Pause, kill queries, etc.
+ CPU/Memory/Load
Sample the system while running
Odoo Workers
Send SIGQUIT to dump worker stacks: kill -3 <odoo_worker_pid>
+ Easy to send from htop
+ Repeat to analyze long running
transactions
Summary
1 Plan and deploy properly, scale as needed
2 Setup precise monitoring
3 Update, Sample, Optimize
This is the basic checklist for performance investigation!
Tech support @ www.odoo.com/help