GatewayWorker运行四五小时后会出现process_timeout问题
workerman.log中的信息
2019-01-04 12:30:15 pid:22312 process_timeout:#1 /usr/MDDeviceService/vendor/workerman/workerman/Events/Select.php(263): pcntl_signal_dispatch()
2 /usr/MDDeviceService/vendor/workerman/workerman/Worker.php(2096): Workerman\Events\Select->loop()
3 /usr/MDDeviceService/vendor/workerman/gateway-worker/src/BusinessWorker.php(190): Workerman\Worker->run()
4 /usr/MDDeviceService/vendor/workerman/workerman/Worker.php(1294): GatewayWorker\BusinessWorker->run()
5 /usr/MDDeviceService/vendor/workerman/workerman/Worker.php(1127): Workerman\Worker::forkOneWorkerForLinux(Object(GatewayWorker\BusinessWorker))
6 /usr/MDDeviceService/vendor/workerman/workerman/Worker.php(1100): Workerman\Worker::forkWorkersForLinux()
7 /usr/MDDeviceService/vendor/workerman/workerman/Worker.php(459): Workerman\Worker::forkWorkers()
8 /usr/MDDeviceService/start.php(52): Workerman\Worker::runAll()
9 {main}
2个回答
年代过于久远,无法发表回答
Events.php的onMessage里的业务代码执行的太慢了,超过了30秒
刚接触这个框架,代码都是之前同事写的,若是要解决这个问题的话,可以从哪方便解决
把Events.php 里上面加上declare(ticks=1);,然后reload。下次发生process_timeout时一般会打印更详细的调用栈,就能知道业务代码是在哪一行执行的慢
另外发生这种情况的时候一般会出现长时间busy的进程,通过手册这个方法也大概能定位到
http://doc.workerman.net/debug/busy-process.html
好的,谢谢!
你好,服务现在已经运行了有大半年,代码修复需要段时间,有没有什么方法可以暂时解决这个问题?
2019-01-08 10:37:22 pid:20248 process_timeout:
1 [internal function]: GatewayWorker\Lib\Statement->__construct(Object(GatewayWorker\Lib\Database))
2 /usr/MDDeviceService/Applications/MDDeviceServer/Events.php(375): PDO->query('INSERT INTO APP...')
3 /usr/MDDeviceService/Applications/MDDeviceServer/Model/DEVModel/DEV_BODY_SIGN_Model.php(117): Events::saveDataToMSSQL(Array)
4 /usr/MDDeviceService/Applications/MDDeviceServer/Model/DEVModel/DEV_BODY_SIGN_Model.php(45): DEV_BODY_SIGN_Model->update()
5 /usr/MDDeviceService/Applications/MDDeviceServer/TransportProtocol.php(86): DEV_BODY_SIGN_Model->__construct('0100007064', 'A55A30313030303...')
6 /usr/MDDeviceService/Applications/MDDeviceServer/Events.php(167): TransportProtocol::handle_data(Object(MDDataModel))
7 [internal function]: Events::onMessage('c0a803660b54000...', 'rrrrrr')
8 /usr/MDDeviceService/vendor/workerman/gateway-worker/src/BusinessWorker.php(384): call_user_func('Events::onMessa...', 'c0a803660b54000...', 'rrrrrr')
9 [internal function]: GatewayWorker\BusinessWorker->onGatewayMessage(Object(Workerman\Connection\AsyncTcpConnection), Array)
10 /usr/MDDeviceService/vendor/workerman/workerman/Connection/TcpConnection.php(657): call_user_func(Array, Object(Workerman\Connection\AsyncTcpConnection), Array)
11 [internal function]: Workerman\Connection\TcpConnection->baseRead(Resource id #86)
12 /usr/MDDeviceService/vendor/workerman/workerman/Events/Select.php(286): call_user_func_array(Array, Array)
13 /usr/MDDeviceService/vendor/workerman/workerman/Worker.php(2096): Workerman\Events\Select->loop()
14 /usr/MDDeviceService/vendor/workerman/gateway-worker/src/BusinessWorker.php(190): Workerman\Worker->run()
15 /usr/MDDeviceService/vendor/workerman/workerman/Worker.php(1294): GatewayWorker\BusinessWorker->run()
16 /usr/MDDeviceService/vendor/workerman/workerman/Worker.php(1127): Workerman\Worker::forkOneWorkerForLinux(Object(GatewayWorker\BusinessWorker))
17 /usr/MDDeviceService/vendor/workerman/workerman/Worker.php(1100): Workerman\Worker::forkWorkersForLinux()
18 /usr/MDDeviceService/vendor/workerman/workerman/Worker.php(1426): Workerman\Worker::forkWorkers()
19 /usr/MDDeviceService/vendor/workerman/workerman/Worker.php(1375): Workerman\Worker::monitorWorkersForLinux()
20 /usr/MDDeviceService/vendor/workerman/workerman/Worker.php(461): Workerman\Worker::monitorWorkers()
21 /usr/MDDeviceService/start.php(52): Workerman\Worker::runAll()
业务处理慢只能业务想办法。看到是insert比较慢,可能是onMessage里批量循环插入了太多的数据导致耗时很高,也可能是mysql死锁或者高负载导致insert很慢
怎么查看是不是由于数据库慢导致的?
@1:busy进程显示了一下就消失了,无法用命令定位具体错误,请问还有其他办法嘛?
短暂的busy是属于正常现象,不用处理
可以正常使用,但是运行一段时间1天左右吧,进程自动超期了,不知道怎么回事,可以取消判断或则其它优化方法吗?