k911 / swoole-bundle

Symfony Swoole Bundle
MIT License
261 stars 46 forks source link

The running server takes all the resources of one core of the CPU. #27

Closed debugger84 closed 5 years ago

debugger84 commented 5 years ago

When I started the app server using bin/console swoole:server:run, I've got load average of a core of a processor in 100%. At the same time, I do not make requests to the site.

%Cpu(s): 13,2 us,  1,3 sy,  0,0 ni, 85,5 id,  0,0 wa,  0,0 hi,  0,0 si,  0,0 st
КиБ Mem : 24515392 total, 14220344 free,  4905336 used,  5389712 buff/cache
КиБ Swap:  9765884 total,  9765884 free,        0 used. 18783208 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                    
14258 yanak     20   0  381220  51752  28124 R 100,0  0,2   0:38.10 php                                                                        

My swoole version is

swoole

swoole support => enabled
Version => 4.2.11
Author => Swoole Group[email: team@swoole.com]
coroutine => enabled
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
sockets => enabled
pcre => enabled
zlib => enabled
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
async_redis => enabled

Directive => Local Value => Master Value
swoole.aio_thread_num => 2 => 2
swoole.display_errors => On => On
swoole.enable_coroutine => On => On
swoole.fast_serialize => Off => Off
swoole.unixsock_buffer_size => 8388608 => 8388608
swoole.use_shortname => On => On

My php version is

PHP 7.2.13-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Dec  7 2018 08:07:36) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.13-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
    with Xdebug v2.6.1, Copyright (c) 2002-2018, by Derick Rethans

Also I tried https://github.com/zendframework/zend-expressive-swoole and it works fine with zend expressive. The load average of CPU was low in idle mode.

k911 commented 5 years ago

Hello @debugger84, the one thing that comes to my mind, and could be responsible for that, is working hmr. It is enabled by default when inotify php extension is installed and you're in debug mode.

Could you please try setting hmr: off in your bundle config file? https://github.com/k911/swoole-bundle/blob/develop/docs/configuration-reference.md

debugger84 commented 5 years ago

Hello @k911, you are right, thank you. Switching value of the swoole.http_server.hmr field to "false" has repaired the problem.

k911 commented 5 years ago

@debugger84 I'll close this issue, since I believe problem is solved. If that's not the point please feel free to reopen.