php中workerman做TCP,使用 workerman 做TCP client 做服务器的压力测试

大家试过workerman/gateway-worker 做为 server 端,能保持多少 TCP 链接吗?

我的情况:

服务器:

Centos 6.8

4核心

16G 内存

已经完全按照 Linux 内核调优参数章节进行了调优

但成功建立 TCP 链接始终不超过两千,达到一千多以后,AsyncTcpConnection的 onError 函数频繁被触发:Error code:1 msg:connect 115.159.77.248:20073 fail after 127.281 seconds

$task = new Worker();

$task->count = 50;

$task->onWorkerStart = function ($task) {

$deviceMaxNumber = 100;

for ($i = 0; $i < $deviceMaxNumber; $i ) {

$taskId = $task->id;

$deviceId = "99999$taskId" . "888887777$i";

require_once __DIR__ . '/SmartLinkBusinessWorker.php';

$busWorker = new \Workerman\SmartLinkBusinessWorker($deviceId);

$connection = new AsyncTcpConnection('lindeProtocol://_._._._:*');

// 当连接建立成功时

$connection->onConnect = ;

$connection->onMessage = ;

$connection->onClose = ;

$connection->onError = ;

$connection->onWorkerStop = ;

$connection->connect();

//sleep(1);

}

};

现在是开启50个进程,每个进程维护100个连接。

这是 “/etc/sysctl.conf” 配置

fs.file-max=6815744

net.ipv4.tcp_max_tw_buckets = 20000

net.ipv4.tcp_sack = 1

net.ipv4.tcp_window_scaling = 1

net.ipv4.tcp_rmem = 4096 87380 4194304

net.ipv4.tcp_wmem = 4096 16384 4194304

net.ipv4.tcp_max_syn_backlog = 262144

net.core.netdev_max_backlog = 32768

net.core.somaxconn = 65535

net.core.wmem_default = 8388608

net.core.rmem_default = 8388608

net.core.rmem_max = 16777216

net.cor

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值