workerman
workerman copied to clipboard
[Feature] Use almost any PHP fw or app with Workerman
Hi Walkor,
I was using a lib internally for more than 2 years, for my legacy apps to run with Workerman v3.5. https://github.com/joanhey/AdapterMan
This week I tested with frameworks, and It's working perfectly, without touch 1 line of code in the fw or app.
We only need an small change to the Front Controller and PHP 8 as minimum.
Tested with:
- Symfony
- Laravel
- Yii2
- Slim
- KumbiaPHP
- ...
Now I'm creating PRs in the Techempower benchmark. https://github.com/TechEmpower/FrameworkBenchmarks/pull/7627 https://github.com/TechEmpower/FrameworkBenchmarks/pull/7626 Later I will push Slim and more fws.
I think that this lib will be useful for more people.
If time permits, I'll try to add documentation and upgrade to Workerman v4
It looks amazing. I thought it was impossible to finish the work, but you solved it easily. Thank you so much for your efforts. 👍
Still fixing small details with the session.
The blog work without any problem. Only the admin area, have small problems with the sessions.
Symfony demo with Workerman, an user authenticated :
Laravel Orchid admin panel with Workerman, with Laravel the login is working
Drupal with Workerman, but still fail the login with symfony.
Laravel and Symfony login working !!!
That great ! 👍
https://user-images.githubusercontent.com/249085/197398600-388ebce3-ece9-4dfa-ba98-fc4d61805e07.mp4
Now I'll create a docker with the symfony-demo. In port 8080 with Workerman and in 8081 with php-fpm.
Symfony initialization 0ms. And half time per request, once loaded the first time.
https://user-images.githubusercontent.com/249085/197398802-fb2bc1e4-ec3d-4a2b-9187-4e40585e5ddc.mp4
Working with CakePHP too
The first results from the bench Without touch a line of code and full ORM.
Laravel 8
Fw | Plaintext | Json | Single query | Multiple query | Updates | Fortunes |
---|---|---|---|---|---|---|
Laravel | 14,799 | 14,770 | 9,263 | 3,247 | 1,452 | 8,354 |
Laravel Roadrunner | 482 | 478 | 474 | 375 | 359 | 472 |
Laravel Swoole | 38,824 | 37,439 | 21,687 | 3,958 | 1,588 | 16,035 |
Laravel Laravel s | 54,617 | 49,372 | 23,677 | 2,917 | 1,255 | 16,696 |
Laravel Workerman | 103,004 | 99,891 | 46,001 | 5,828 | 1,666 | 27,158 |
Laravel with Workerman % gain | 596.02% | 576.31% | 396.61% | 79.489% | 14.738% | 225.09% |
In 2 days Symfony. The next week: Laravel 9, Lumen 9, Cakephp and Slim.
Very good. It seems that the performance improvement is significant. 👍
Yes, it's very significant. And here the results are bad, for using the very slow Laravel ORM.
The next week, we will see the Slim with raw db and optimized db for workerman.
I don't know any PHP ORM optimised for persistent apps.
The latency is really good !!
And later, we will check the memory used. Kumbiaphp use half the memory using Workerman. We will have better numbers with other fws.
Symfony 6
700% faster in the Fortunes
Latency
Fw | Plaintext | Json | Single query | Multiple query | Updates | Fortunes |
---|---|---|---|---|---|---|
Symfony | 38,231 | 37,557 | 12,578 | 10,741 | 3,420 | 10,741 |
Symfony Workerman | 210,796 | 197,059 | 107,050 | 13,401 | 4,062 | 71,092 |
https://github.com/joanhey/AdapterMan#performance-bench :)
With CakePHP we have worst results with Workerman. :( I'll investigate if it's an error or directly a problem with CakePHP
I think that I found the problem, It's related to Cakephp. Changes passed, and in 7 days we have the new results. https://github.com/TechEmpower/FrameworkBenchmarks/pull/7680
Looking the cakephp bootstrap, it check if is CLI SAPI, and load a cli bootstrap.
Laravel 9 have the same numbers than version 8.
Lumen 9
Fw | Plaintext | Json | Single query | Multiple query | Updates | Fortunes |
---|---|---|---|---|---|---|
Lumen | 18,998 | 18,616 | 10,791 | 3,496 | 1,461 | 9,223 |
Lumen Swoole | 44,861 | 43,598 | 24,255 | 4,178 | 1,599 | 16,854 |
Lumen Laravel s | 93,335 | 82,745 | 31,567 | 3,030 | 1,282 | 21,130 |
Lumen Workerman | 185,126 | 177,667 | 58,729 | 5,857 | 1,662 | 31,430 |
Very similar numbers to Laravel.
Trying now with Codeigniter4
Performance info
Slim3 vs Slim4 without ORM
Framework | JSON | 1-query | 20-query | Fortunes | Updates | Plaintext |
---|---|---|---|---|---|---|
Slim 3 | 35,588 | 29,529 | 12,579 | 28,211 | 1,999 | 36,247 |
Slim 4 | 38,305 | 34,272 | 12,579 | 32,634 | 2,097 | 35,251 |
:+1:
Slim with Workerman
Without ORM
Framework | JSON | 1-query | 20-query | Fortunes | Updates | Plaintext |
---|---|---|---|---|---|---|
Slim 4 | 38,305 | 34,272 | 12,579 | 32,634 | 2,097 | 35,251 |
Slim 4 Workerman | 129,393 | 81,889 | 15,803 | 73,212 | 2,456 | 134,531 |
Slim 4 Workerman pgsql * | 102,926 | 19,637 | 92,752 | 14,875 |
- Without ORM and db class optimized for Workerman
CakePHP still slower. Asking for help in the Cakephp slack.
I'm updating all fw to php 8.2, in the bencmark.
But Workerman 3.5 have problems with dynamic properties.
And fail in some frameworks.
Can we move it from 3.5 to v4, as another protocol ? So we also could optimize it for php 7.
In the mean time, you or me can add #[\AllowDynamicProperties] To the Worker class and Connection interface.
In the mean time, you or me can add #[\AllowDynamicProperties] To the Worker class and Connection interface.
Done
Walkor, open a twitter for Workerman (and Webman).
Hi joanhey, here are the twitter accounts.
https://twitter.com/workermanphp https://twitter.com/webmanphp
Lumen v9
600% faster
Great 👍
When you have a moment, Could we talk in private ? Thank you