Closed RicardoSette closed 4 years ago
I think you should open a issue an ask this possibility before because of: https://github.com/the-benchmarker/web-frameworks/pull/1335 and https://github.com/the-benchmarker/web-frameworks/issues/1502
The author doesn't seems to be open for Swoole related additions, maybe because of https://github.com/the-benchmarker/web-frameworks/issues/1481
There are projects using Swoole, such as: "one" / "Hyperf" / "simps", exemple configure in php/one project:
framework:
github: lizhichao/one
version: 2.0
php_ext:
- swoole
command: php App/swoole.php
Just configure yaml correctly for the Swoole extension to be installed, and running the command to start the Swoole server instead of using nginx+php-fpm.
Oh, how cool. I thought the repo isn't accepting Swoole based applications until the variations thing was resolved/closed.
Tests are just about returning empty strings?
I think we can work on something then.
I added two Siler projects, for PHP-FPM and Swoole.
https://github.com/RicardoSette/web-frameworks/tree/yii2-swoole/php/siler https://github.com/RicardoSette/web-frameworks/tree/yii2-swoole/php/siler-swoole
The code and settings are simple, but you could revise, if you have something to add or remove to improve performance.
Ok, I'll be sending a PR to your repo with some mods.
This is the project with the highest score in PHP:
https://github.com/the-benchmarker/web-frameworks/tree/master/php/workerman
I was reviewing and I believe that Siler could be run in the same way, without Swoole and without PHP-FPM, do you think that could increase performance?
This makes the use of PHP's built-in web server it is not suited for production environments.
Hi @leocavalcante,
is there any planning or way to change Swoole settings?
See as an example this project https://github.com/the-benchmarker/web-frameworks/blob/master/php/simps/config/servers.php
Simps is now the first PHP Framework in the benchmarker list and Swoole's start configurations can be one of the differentials.
Let's see if we can take advantage of the change request at https://github.com/the-benchmarker/web-frameworks/pull/2598 to review Swoole settings on Siler
Please not that the above results are not, yet, production-ready, until https://github.com/the-benchmarker/web-frameworks/pull/2593 is merged :heart:
Yes, I know that, it's more to leave the Siler at full strength for the first test :sunglasses:
Hi @RicardoSette
The http
function returns a Swoole\Http\Server
, so instead of:
http($handler, $port, $host)->start();
You can:
$server = http($handler, $port, $host);
$server->set([
// Swoole settings like:
'worker_num' => (int) shell_exec('nproc') ?? 32
]);
$server->start();
In PHP projects Siler ranked fourth, but in test above 64 the position would be third 💪🔝
The first and second positions are outside the curve, the first with practically pure Swoole and the second with different uses of POSIX and PCNTL extensions. Then look at these two projects to add more performance to Siler.
Congratulations 😎
@RicardoSette cool! I should inspect and study why Simps performs so much better in Swoole, Siler is practically pure PHP and pure Swoole as well, it only provides facades. Thanks for bringing this up!
I found the reason why Simps got 175,713 points and Siler-Swoole got 64,343
Simps runs the swoole with Swoole\Server Siler runs the swoole with Swoole\Http\Server
In tests on my virtual machine, when I run in the settings above I have:
Simps (Swoole\Server) => 11256 req / s Siler (Swoole\Http\Server) => 4946 req / s
When I put Simps to run with Swoole \ Http \ Server see how it looks:
Simps (Swoole\Http\Server) => 5609 req / s Siler (Swoole\Http\Server) => 4849 req / s
I didn't find how to run Siler with Swoole\Server, is that possible?
When both use Swoole\Http\Server we notice a small gain from Simps over Siler, but it may be due to the use of nikic/fast-route or the fact that there are no controls like Container\set
Awesome! Thank you very much for digging into this.
Yeah, it is skipping Swoole's HTTP parsing and making its own: https://github.com/simple-swoole/simps/blob/master/src/Server/Protocol/HTTP/SimpleRoute.php#L55 Cleaver.
@RicardoSette @leocavalcante may I ask for your review when implementation of siler
is updated ? (or a minor version is release, I always use the last patch)
@waghanza sure!
@RicardoSette Siler faster than Simps on the latest round: https://github.com/the-benchmarker/web-frameworks/tree/cloudify#results
@leocavalcante updated and returned to the standards of the first test. If it were possible to configure Siler to work with Swoole\Server then it could be close to or above the Simps.
@RicardoSette yeah, I misread the first published results lol. Do you know a good use case for doing raw sockets + naive method and path parsing, besides just being faster? Maybe in some specific micro-services where you just need the url path to route to something, but on real case scenarios you would need at least the headers and body I guess.
The sky is the limit, we can have simple internal systems for message alerts where the URL would be the trigger, but we also have more complex IoT systems (mqtt) like those used for arduino.
Of course, the default is HTTP server, but the creation of simplistic servers with only TCP / UDP could be an option for the developer.
I found a project to benchmark Web Frameworks, want help adding the Siler with Swoole? I believe he will be in the Top 10.
The link: https://github.com/the-benchmarker/web-frameworks