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

AsyncTcpConnection并發(fā)連接測試,ChatGateway內(nèi)存一直增長

TKOL

使用文檔中給的AsyncTcpConnection并發(fā)連接測試,ChatGateway內(nèi)存一直增長
時間越長,內(nèi)存大小超過10G

----------------------------------------------GLOBAL STATUS----------------------------------------------------
Workerman version:3.5.11          PHP version:5.5.99-hiphop
start time:2018-07-02 18:00:49   run 0 days 0 hours
load average: 8.91, 10, 13       event-loop:\Workerman\Events\Select
4 workers       51 processes
worker_name        exit_status      exit_count
ChatBusinessWorker 0                0
ChatGateway        0                0
Register           0                0
WebServer          0                0
----------------------------------------------PROCESS STATUS---------------------------------------------------
pid memory  listening                worker_name        connections send_fail timers  total_request qps    status
3984    6.13M   none                     ChatBusinessWorker 25          0         1       25904         28     
3985    6.14M   none                     ChatBusinessWorker 25          0         1       25834         27     
...
4008    6.13M   none                     ChatBusinessWorker 25          0         1       25926         29     
4009    6.15M   none                     ChatBusinessWorker 25          0         1       25762         28     
4010    28.41M  websocket://0.0.0.0:8272 ChatGateway        455         0         3       680830        795    
4011    28.45M  websocket://0.0.0.0:8272 ChatGateway        455         0         3       680586        756    
...
4033    27.89M  websocket://0.0.0.0:8272 ChatGateway        402         0         3       672936        797    
4035    28.4M   websocket://0.0.0.0:8272 ChatGateway        451         0         3       680821        766    
4036    5.75M   text://0.0.0.0:8236      Register           48          0         0       1077          0      

----------------------------------------------PROCESS STATUS---------------------------------------------------
Summary 828M    -                        -                  11308       0         96      16924905      19481  

Press Ctrl+C to quit.

測試腳本:

require __DIR__ . '/vendor/autoload.php';
use Workerman\Worker;
use Workerman\Lib\Timer;
use Workerman\Connection\AsyncTcpConnection;

$worker = new Worker();
$worker->onWorkerStart = 'connect';
function connect(){
    static $count = 0;
    echo $count . "\n";
    if ($count++ >= 10000) return;
    // 建立異步鏈接
    $con = new AsyncTcpConnection('ws://127.0.0.1:8272');
    $con->onConnect = function($con) {
        // 遞歸調(diào)用connect
        connect();
    };
    $con->onMessage = function($con, $msg) {
        $msgInfo = json_decode($msg, true);
        if(isset($msgInfo) && $msgInfo == 'ping'){
            $con->send('{"type":"pong"}');
        }
        echo "r $msg\n";
    };
    $con->onClose = function($con) {
        echo "con close\n";
    };

    Timer::add(5, function()use($con){
        $con->send('{"type":"pong"}');
    });
    $con->connect();
    echo $count, " connections complete\n";
}
Worker::$stdoutFile = '/home/work/im/workerman-chat/start_qa.log';
Worker::runAll();

event.php

use \GatewayWorker\Lib\Gateway;

class Events
{

    public static function onConnect($client_id)
    {
        $new_message = array(
            'id'=>$client_id,
        );

        Gateway::sendToCurrentClient(json_encode($new_message));
    }

   /**
    * 有消息時
    * @param int $client_id
    * @param mixed $message
    */
   public static function onMessage($client_id, $message)
   {
       Gateway::sendToCurrentClient( json_encode(Gateway::getAllClientIdCount()));
       return ;
   }

   /**
    * 當客戶端斷開連接時
    * @param integer $client_id 客戶端id
    */
   public static function onClose($client_id)
   {
   }

}
4056 4 0
4個回答

walkor 打賞

根據(jù)手冊,壓測需要安裝event擴展并按照手冊優(yōu)化linix內(nèi)核

  • 暫無評論
TKOL

安裝event擴展并按照手冊優(yōu)化linix內(nèi)核就能解決這個問題了嗎?
那就是說現(xiàn)在是正常現(xiàn)象是嗎?

  • 暫無評論
walkor 打賞

安裝event擴展并按照手冊優(yōu)化linix內(nèi)核后不會占用無限增長。
沒有安裝event擴展,默認使用select IO復(fù)用,最多支持1000連接,超過1000的連接會造成內(nèi)存泄漏。
內(nèi)存無限增長肯定不是正常現(xiàn)象。

  • 暫無評論
TKOL

好的,那我優(yōu)化后再試試,感謝

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