国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

SendBufferToWorker fail

bijingjieshen

程序啟動如下所示:

$ sudo php start.php start
Workerman start in DEBUG mode
----------------------- WORKERMAN -----------------------------
Workerman version:3.3.9          PHP version:5.3.3
------------------------ WORKERS -------------------------------
user          worker                  listen                          processes status
root          YourAppBusinessWorker   none                             1          
root          JDwuliu-YourAppGateway  json://192.168.1.105:8185        1          
root          JDwuliu-HttpGateway     http://192.168.1.105:8184        1          
root          Register                text://192.168.1.105:1242        1          
root          JDwuliu-WebGateway      websocket://192.168.1.105:8188   1          
----------------------------------------------------------------
Press Ctrl-C to quit. Start success.

在成功啟動幾個小時后,cpu會增長到90%多,然后日志開始報錯:

2017-09-12 10:53:32 pid:72082 SendBufferToWorker fail. The connections between Gateway and BusinessWorker are not ready. See http://wiki.workerman.net/Error3 for detail,

導致JDwuliu-HttpGateway這個進程不會接收數(shù)據(jù),但是JDwuliu-YourAppGateway和JDwuliu-WebGateway 。請問這是什么原因呢???

4153 11 0
11個回答

walkor 打賞

哪個進程占用cpu 90%?

  • 暫無評論
bijingjieshen

pid memory listening worker_name connections total_request send_fail throw_exception
16758 4.25M none YourAppBusinessWorker 4 673 0 0
16759 2.75M json://192.168.1.105:8185 JDwuliu-YourAppGateway 2 1 0 0
16760 2.75M http://192.168.1.105:8184 JDwuliu-HttpGateway 2 3 0 0
16761 2.5M text://192.168.1.105:1242 Register 4 2440 0 0
16762 2.75M websocket://192.168.1.105:8188 JDwuliu-WebGateway 3 24930 0 0

pid為16758 這個進程

  • 暫無評論
walkor 打賞

應(yīng)該是你們服務(wù)器沒裝event擴展導致的。
在線數(shù)超過1000需要是要裝event擴展的。
另外還要根據(jù)workerman手冊優(yōu)化linux內(nèi)核。

  • 暫無評論
bijingjieshen

安裝了libevent,也優(yōu)化了內(nèi)核參數(shù),但是cpu還是會蹦到90%,業(yè)務(wù)代碼如下(websocket協(xié)議)

//查詢所有車輛id
$cars_id = $db1->select('car_id')->from('carinfo')->query();

foreach($cars_id as $car_id)
{
    $gps_data = $db1->select('gps_lon,gps_lat')->from($car_id.'_LOCATIONINFO')->orderByDESC(array('u_id'))->limit(1)->query();
    $gps_data = $car_id;
    //查詢車輛類型
    $type = $db1->select('type')->from('carinfo')->where("car_id = '{$car_id}'")->query();
    $gps_data = $type;
    $ret = insert_lesson($query_data, "data", $gps_data);
}

//正在運行中
$trans_car_data = $db1->query("select count(*) from carinfo where status = '0'");

//停止
$idle_car_data = $db1->query("select count(*) from carinfo where status = '1'");

//正在運行中
$hitch_car_data = $db1->query("select count(*) from carinfo where hitch = '1'");

//車輛狀態(tài)統(tǒng)計
$car_status = array("trans_car" => $trans_car_data,
    "hitch_car" => $hitch_car_data,
    "idle_car" => $idle_car_data);

$all_cars_data = array("resData" => array
("result" => 0,
    "msg" => "查詢成功",
    "data" => $query_data,
    "status" => $car_status));

Gateway::sendToClient($client_id, json_encode($all_cars_data));

$timer_id = Timer::add(3, function()use($client_id, $db1)
{.......}

做了個定時器定時器中的內(nèi)容就和上面的代碼一樣,目的就是每三秒發(fā)送實時車輛數(shù)據(jù)給web端。我通過explain查看了執(zhí)行計劃只有count(*)這個是全表掃描,而且整個表也就30行左右的數(shù)據(jù)。到底是哪占用了這么高的cpu呢?

  • 暫無評論
walkor 打賞

定時器什么時候添加的,onMessage時候添加的?
你的情況有可能是不停的添加定時器導致的。
預(yù)期是3秒運行一次,結(jié)果沒處理好不停的添加定時器,每秒運行成千上萬次,也會導致cpu 很高

  • 暫無評論
bijingjieshen

是在onMessage的時候添加的。是一個websocket接口,我的目的前端創(chuàng)建了一個websocket,然后訪問過這個接口,我就每三秒回一次最新的數(shù)據(jù)給web端,不需要它再次請求,它只要接收就好了。當web頁面跳轉(zhuǎn)的時候,websocket就斷了。目標是創(chuàng)建一次定時器,然后自動銷毀。難道不是這樣嗎?

  • 暫無評論
bijingjieshen

而且我通過tcpdump抓包,確實是每三秒發(fā)送一次數(shù)據(jù)

  • 暫無評論
walkor 打賞

用命令
strace -ttp cpu高的進程pid
看下進程在干嘛吧。
一般來說都是業(yè)務(wù)代碼問題

  • 暫無評論
bijingjieshen

找到問題了,按照你的方法用strace 命令跟蹤了一下pid,發(fā)現(xiàn)即使把web端頁面關(guān)了,之前加的定時器還在跑,所以做了如下修改

$_SESSION = Timer::add(2, function()use($client_id, $db1, $car_id, $redis1)

    public static function onClose($client_id) {

       if(isset($_SESSION))
       {
           Timer::del($_SESSION);
       }
}

在斷開的時候把定時器給銷毀了。我原以為在websocket斷開的時候定時器會自動銷毀,所以才導致了上面的問題,謝謝@walkor 大神

  • 暫無評論
walkor 打賞

好的,看來還是無限加定時器的問題導致

  • 暫無評論
bijingjieshen

是的是的,非常感謝?。。?/p>

  • 暫無評論
年代過于久遠,無法發(fā)表回答
??