使用多个工作进程时,Odoo / OpenERP中的高空闲负载

时间:2016-03-10 12:12:02

标签: python performance multiprocessing odoo strace

我想分享一下Odoo V9 ERP系统的性能分析结果。

问题/症状

当在odoo中运行多个工作进程时,odoo连续消耗1个cpu而没有任何请求,因此我们的平均系统负载<1。

top - 12:13:54 up 1 day, 35 min,  3 users,  load average: 0.92, 0.82, 0.79
Tasks: 149 total,   3 running, 146 sleeping,   0 stopped,   0 zombie
%Cpu0  :  0.0 us,  3.7 sy,  0.0 ni, 96.3 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu1  : 63.0 us, 20.4 sy,  0.0 ni, 16.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu2  :  5.6 us,  0.0 sy,  0.0 ni, 94.4 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu3  :  5.6 us,  7.4 sy,  0.0 ni, 85.2 id,  0.0 wa,  0.0 hi,  0.0 si,  1.9 st
KiB Mem:   4047120 total,  1660760 used,  2386360 free,   159696 buffers
KiB Swap:  4194300 total,        0 used,  4194300 free.  1040260 cached Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
12345 odoo      20   0  226576  59732  13184 S   9.3  1.5   0:50.94 odoo.py

分析

ps -eo pcpu,pid,user,args | sort -b -k1,1n

最后一行显示了cpu消耗过程。通常应该是与#34; top&#34;顶部相同的PID。

0.3 12345 odoo     /usr/bin/python /usr/bin/openerp-gevent --config /etc/odoo/openerp-server.conf --logfile /var/log/odoo/odoo-server.log

所以,我们正在运行一个strace:

strace -o 12345.log -vtffp 12345

几秒钟后,您可以使用STRG-C

断开连接

现在您可以找到一些像

这样的文件
  • 12345.log.12345
  • 12345.log.12346
  • 12345.log.12347
  • 12345.log.12349

如果您的strace将停止子进程

12:13:54 stat("/usr/lib/pymodules/python2.7/psycogreen", 0x7fffcf562920) = -1 ENOENT (No such file or directory)
12:13:54 open("/usr/lib/pymodules/python2.7/psycogreen.x86_64-linux-gnu.so", O_RDONLY) = -1 ENOENT (No such file or directory)
12:13:54 open("/usr/lib/pymodules/python2.7/psycogreen.so", O_RDONLY) = -1 ENOENT (No such file or directory)
12:13:54 open("/usr/lib/pymodules/python2.7/psycogreenmodule.so", O_RDONLY) = -1 ENOENT (No such file or directory)
12:13:54 open("/usr/lib/pymodules/python2.7/psycogreen.py", O_RDONLY) = -1 ENOENT (No such file or directory)
12:13:54 open("/usr/lib/pymodules/python2.7/psycogreen.pyc", O_RDONLY) = -1 ENOENT (No such file or directory)
12:13:54 write(2, "Traceback (most recent call last"..., 35) = 35
12:13:54 write(2, "  File \"/usr/bin/openerp-gevent\""..., 54) = 54
12:13:54 open("/usr/bin/openerp-gevent", O_RDONLY) = 4
12:13:54 fstat(4, {st_dev=makedev(252, 0), st_ino=1062415, st_mode=S_IFREG|0755, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_size=196, st_atime=2016/03/09-16:12:19, st_mtime=2016/02/19-13:13:35, st_ctime=2016/03/09-16:10:52}) = 0
12:13:54 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f02133e1000
12:13:54 read(4, "#!/usr/bin/env python\n\nimport ge"..., 4096) = 196
12:13:54 write(2, "    ", 4)            = 4
12:13:54 write(2, "import psycogreen.gevent\n", 25) = 25
12:13:54 close(4)                       = 0
12:13:54 munmap(0x7f02133e1000, 4096)   = 0
12:13:54 write(2, "ImportError", 11)    = 11
12:13:54 write(2, ": ", 2)              = 2
12:13:54 write(2, "No module named psycogreen.geven"..., 33) = 33
12:13:54 write(2, "\n", 1)              = 1
12:13:54 rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x7f0212fb4340}, {0x45a0f5, [], SA_RESTORER, 0x7f0212fb4340}, 8) = 0
12:13:54 exit_group(1)                  = ?
12:13:54 +++ exited with 1 +++

1 个答案:

答案 0 :(得分:1)

解决方案

只需安装psycogreen模块即可。 ;)

apt-get install python-pip
pip install psycogreen

我希望它对其他Odoo用户有帮助