Swoole版本:4.3对swoole_websocket_server压测时,使用这个方法可行吗?//代码片段$this->concurrency=100;$this->request=100000;go(function(){for($c=$this->concurrency;$c--;){$cli=new\Swoole\Coroutine\Http\Client('127.0.0.1',9501);$ret=$cli->upgrade('/');if($ret){while($this->requested<$this->request){$this->push($cli);$cli->recv();}}}});官方使用的swoole_http_client在4.3版本移除了。另外:使用Task或不使用Task,压测时会有很大区别吗,目前本地测着区别不大,是这样的吗?//使用Task代码$this->serv->on('message',function($serv,$frame){$serv->task($frame->data);});$this->serv->on('task',function($serv,$task){foreach($serv->connectionsas$fd){$connectionInfo=$serv->connection_info($fd);if(isset($connectionInfo['websocket_status'])&&intval($connectionInfo['websocket_status'])==3){$serv->push($fd,$task->data);}}});//未使用Task代码$this->serv->on('message',function($server,$frame){foreach($this->serv->connectionsas$fd){$connectionInfo=$this->serv->connection_info($fd);if(isset($connectionInfo['websocket_status'])&&intval($connectionInfo['websocket_status'])==3){$server->push($fd,$frame->data);}}});机器信息Mac上安装的ParallelsDesktop虚拟机系统:Ubuntu16.04.3LTS内存:数量:1核数:2CPU:数量:1大小:2GConcurrency:100Requestnum:100000Successnum:100000Totaltime:8.9364Requestpersecond:11190请前辈们指点,这个量级有问题吗?感谢!
手掌心
相关分类