Odoo Performance
Odoo Performance
Odoo
Olivier Dony
@odony
Performance issues
can be (easily) solved
With the right tools
And the right facts
Odoo Performance
o1 Some Facts
2
Deployment Architecture
Some Facts
PostgreSQL
o Is the real workhorse of your Odoo server
o Powers large cloud services
o Can handle terabytes of data efficiently
o Should be fine-tuned to use your hardware
o Cannot magically fix algorithmic/complexity
issues in [y]our code!
Hardware Sizing
o 2014 recommandation for single user
server for up to ~100 active users
o Intel Xeon E5 2.5Ghz 6c/12t (e.g. E5-1650v2)
o 32GB RAM
o SATA/SAS RAID-1
Transaction Sizing
o Typical read transaction takes ~100ms
o A single process can handle ~6 t/s
o 8 worker processes = ~50 t/s
o 1 interactive user = ~50 t/m peak = ~1 t/s
o Peak use with 100 users = 100 t/s
o On average, 5-10% of peak = 5-10 t/s
SQL numbers
o Most complex SQL queries should be under
100ms, and the simplest ones < 5ms
o RPC read transactions: <40 queries
o RPC write transactions: 200+ queries
o One DB transaction = 100-300 heavy locks
Sizing
Deployment
Odoo Architecture
Front-end pages
Back-end JS client
HTTP Routing
User Interface
Controllers
Models
ORM
PostgreSQL Store
Persistence
Deployment Architecture
Single server, multi-process
HTTP worker
Requests
HTTP worker
HTTP worker
PostgreSQL
Store
Cron worker
gevent worker
Deployment Architecture
Multi-server, multi-process
HTTP worker
HTTP worker
HTTP worker
Requests
Load
balancer
Cron worker
gevent worker
HTTP worker
HTTP worker
HTTP worker
Cron worker
gevent worker
PostgreSQL
Store
PostgreSQL Deployment
o Use PostgreSQL 9.2/9.3 for performance
o Tune it:
http://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server
Monitor
& Measure
-n "min.value "
${result} | cut -d" " -f1
-n "avg.value "
${result} | cut -d" " -f2
0
Monitor PostgreSQL
o Munin has many builtin plugins (enabled with
symlinks)
o Enable extra logging in postgresql.conf
o log_min_duration_statement = 50
o lc_messages = 'C'
Analyze
PostgreSQL Analysis
o Important statistics tables
o pg_stat_activity: real-time queries/transactions
o pg_locks: real-time transaction heavy locks
o pg_stat_user_tables: generic use stats for tables
o pg_statio_user_tables: I/O stats for tables
num_rows
179544
134039
97195
96973
83077
69011
59532
58942
49714
46258
table
total_size
public.stock_move
525 MB
public.wkf_workitem
111 MB
public.procurement_order
80 MB
public.stock_location
63 MB
public.ir_translation
42 MB
public.wkf_instance
37 MB
public.ir_model_data
36 MB
public.ir_property
26 MB
public.ir_attachment
14 MB
public.mrp_bom
13 MB
table
disk_reads cache_reads total_reads
public.stock_location
2621
525023173
525025794
public.product_product
11178
225774346
225785524
public.mrp_bom
27198
225329643
225356841
public.ir_model_fields
1632
203361139
203362771
public.stock_production_lot
5918
127915614
127921532
public.res_users
416
115506586
115507002
public.ir_model_access
6382
104686364
104692746
public.mrp_production
20829
101523983
101544812
public.product_template
4566
76074699
76079265
public.product_uom
18
70521126
70521144
public.wkf_workitem
129166
67782919
67912085
seq_scan
idx_scan
1188095
226774
373
41402098
297984
190934
270568
30161
656404
246636
1104711719
22134417
17340039
166316501
71732467
28038527
13550371
4757426
97874788
818
lines_read_total
num_insert
num_update
num_delete
132030135782
11794090805
29910699
516216409246
5671488265
1124560295
476534514
60019207
5054452666
2467441
208507
92064
1958392
97
9008
4318
3816
2077
5914
0
9556574
6882666
3280141
2215107
1000966
722053
495776
479752
404469
169904
67298
27543
1883794
205
1954
0
1883
320
0
0
Analysis Locking
o Verify blocked queries
# SELECT * FROM waiter_holder;
relname | wpid | hpid |
wquery
| wdur
| hquery
---------+-------+-------+--------------------------------+------------------+----------------------------| 16504 | 16338 | update "stock_quant" set "s
| 00:00:57.588357 | <IDLE> in transaction
| 16501 | 16504 | update "stock_quant" set "f
| 00:00:55.144373 | update "stock_quant"
(2 lignes)
...
hquery
| hdur
|
wmode
|
hmode
|
... ------------------------------+-------------------+-----------+---------------|
... <IDLE> in transaction
| 00:00:00.004754
| ShareLock | ExclusiveLock |
... update "stock_quant" set "s
| 00:00:57.588357
| ShareLock | ExclusiveLock |
Top 5
Problems
in Custom Apps
5. Custom Locking
o In general PostgreSQL and the ORM do all the DB and
Python locking we need
o Rare cases with manual DB locking
o Inter-process mutex in db (ir.cron)
o Sequence numbers
o Reservations in double-entry systems
o Python locking
o Caches and shared resources (db pool)
Thank You
Odoo
[email protected]
+32 (0) 2 290 34 90
www.odoo.com
@odony