压力测试显示Throughput: 0.00 [#/sec]

commandoeer

8核,tcp开了64个进程,压测显示 Throughput: 0.00

2414 5 0
5个回答

walkor

请贴代码和压测脚本命令

  • 暂无评论
commandoeer

全部是采用默认的代码:
tcp.php

use Workerman\Worker;
require_once './workerman/Autoloader.php';

$worker = new Worker('tcp://0.0.0.0:1234');
$worker->count=64;
$worker->onMessage = function($connection, $data)
{
    // 长连接
    $connection->send("HTTP/1.1 200 OK\r\nConnection: keep-alive\r\nServer: workerman\1.1.4\r\n\r\nhello");
    // 短连接
    //$connection->close("HTTP/1.1 200 OK\r\nServer: workerman\1.1.4\r\n\r\nhello");
};
Worker::runAll();

压力测试:

./benchmark -n1 -h10000 -c1000 -p1234 127.0.0.1 

输出:

Recieved 72 bytes
Recieved 72 bytes
Recieved 72 bytes
Throughput: 0.00 
  • 暂无评论
commandoeer

用ab 测试是可以的,这个压测脚本最后没有输出结果。

  • 暂无评论
walkor

./benchmark 做不了http协议的压测,它只发hello,服务端必须回复hello。

$connection->send('hello');

walkor

....
你的代码是在tcp的基础上以http协议发送的

"HTTP/1.1 200 OK\r\nConnection: keep-alive\r\nServer: workerman\1.1.4\r\n\r\nhello"

这个是http协议的数据

要用benchmark,onmessage里面改成

$connection->send('hello');

  • 暂无评论
年代过于久远,无法发表回答
🔝