Thank you for you good library.
Please answer these questions before submitting your issue. Thanks!
在提交Issue前请回答以下问题:
I made test with 2000 rps, 10 concurency.
I took your simple example:
$server = new Swoole\Http\Server('0.0.0.0', 1080);
$server->set(['worker_num' => 1,]);
$server->on('Request', function($request, $response) {$response->end(' swoole response is ok');});
$server->start();
I got this result:
100% < 15.49 ms
99% < 8.28 ms
98% < 4.35 ms
95% < 0.72 ms
90% < 0.26 ms
85% < 0.23 ms
80% < 0.21 ms
75% < 0.20 ms
50% < 0.17 ms
I also took workerman example:
require_once __DIR__ . '/vendor/autoload.php';
use Workerman\Worker;
Worker::$eventLoopClass = '\Workerman\Events\Ev';
$http_worker = new Worker("http://0.0.0.0:1080");
$http_worker->count = 1;
$http_worker->onMessage = function($connection, $data)
{$connection->send("hello world \n");};
Worker::runAll();
I got this result:
100% < 3.88 ms
99% < 1.09 ms
98% < 0.94 ms
95% < 0.75 ms
90% < 0.63 ms
85% < 0.55 ms
80% < 0.52 ms
75% < 0.49 ms
50% < 0.43 ms
Workerman is more slow 2-3 times.
I installed event library (pecl install event) and enabled it in code Worker::$eventLoopClass = '\Workerman\Events\Ev';
I got this result:
100% < 6.59 ms
99% < 0.37 ms
98% < 0.23 ms
95% < 0.17 ms
90% < 0.15 ms
85% < 0.15 ms
80% < 0.14 ms
75% < 0.13 ms
50% < 0.11 ms
It is faster 4 times then previous version and 1.5 times then swoole.
I need to be faster :)
How can I use libevent with swoole or how can I change epoll to something else?
socket select is very slow.
php --ri swoole)?1.9.18
4.8.0-52-generic #55-Ubuntu SMP Fri Apr 28 13:28:50 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
PHP 7.0.18
gcc (Ubuntu 6.2.0-5ubuntu12) 6.2.0 20161005
no ssl
Thank you for you good library again.
The default use of SWOOLE_PROCESS mode, there will be two IPC(inter-process communication.).
You can use the SWOOLE_BASE mode.
Swoole is based on epoll, no need libevent.
$server = new Swoole\Http\Server('0.0.0.0', 1080, SWOOLE_BASE);
$server->set(['worker_num' => 1,]);
$server->on('Request', function($request, $response) {$response->end(' swoole response is ok');});
$server->start();
More faster?) May be you must use GO? Swoole fastest library in PHP.
@matyhtf thank you very match.
workerman:
100% < 7.76 ms
99% < 0.91 ms
98% < 0.66 ms
95% < 0.51 ms
90% < 0.45 ms
85% < 0.40 ms
80% < 0.38 ms
75% < 0.36 ms
50% < 0.26 ms
swoole:
100% < 6.54 ms
99% < 1.78 ms
98% < 0.60 ms
95% < 0.44 ms
90% < 0.36 ms
85% < 0.32 ms
80% < 0.29 ms
75% < 0.27 ms
50% < 0.19 ms
@coollider now I am faster enough.
My colleagues write code on go and whey are faster then me only two times but they spend for writing more then me ten times. https://highloadcup.ru/rating/ When I will need to write code faster than php I will write it on C :)