symfony / symfony-docs

The Symfony documentation
https://symfony.com/doc
Other
2.18k stars 5.13k forks source link

Add performance advanced solutions #17428

Closed raziel057 closed 1 year ago

raziel057 commented 2 years ago

As we can see more and more solution trying to run Symfony with async event driven or other modern servers (swoole, openswoole, amp, workerman, frankenphp), it would be interesting to provide tips or links to the different solutions. It could be added in a specific section of the https://symfony.com/doc/current/performance.html page.

Frankenphp and Workerman support with AdapterMan seems particularly interesting (see last benchmark here). It use the exact same code.

Maybe it would make sense to increase the popularity of these solutions, by providing advises (pro/cons).

References https://frankenphp.dev/ https://github.com/joanhey/AdapterMan https://github.com/walkor/workerman https://openswoole.com/ https://github.com/swoole/swoole-src

joanhey commented 2 years ago

Added Frankenphp to the bench. https://github.com/TechEmpower/FrameworkBenchmarks/pull/7748

Now only in normal mode with plain php. Later I'll try with Worker mode and Symfony.

joanhey commented 1 year ago

Added Symfony Swoole using phpruntime https://github.com/TechEmpower/FrameworkBenchmarks/pull/7753

raziel057 commented 1 year ago

@joanhey thank you. Good to see viable solutions that improves performances of high quality PHP Frameworks.

joanhey commented 1 year ago

Added Symfony with Frankenphp in Worker mode using phpruntime https://github.com/TechEmpower/FrameworkBenchmarks/pull/7756

javiereguiluz commented 1 year ago

@joanhey thanks for working on this 🙏

Just out of curiosity, how are the numbers that you see when running these benchmarks on your local machine? How much faster is the app when running via FrankenPHP? Thanks.

joanhey commented 1 year ago

Hola Javier

Normally I don't bench locally because it's unrealistic, but we get some numbers in the test verification. But this latency time is with only 1 user, it's more important the scalability. With more req/s, the latency scale very fast. Plain php have a very low latency, but don't scale with fastcgi.

Symfony Fortunes test

Fastcgi: image

Swoole using phpruntime: image

Frankenphp using phpruntime: image

Workerman using Adapterman: image

joanhey commented 1 year ago
joanhey commented 1 year ago

The initial tests are not too good for FrankenPHP. But remember that is new, and need more work and optimizations. These numbers will be better with time. And I'm in contact with dunglas, to help with any information.

Still not finished the run, also no results from Swoole and Workerman without a framework yet (in 2 days will finish the run).

Only platform runtimes without a framework, FrankenPHP without Worker mode: image Latency image

In some hours we will have all Symfony runtimes using the same code, and will be a more fair comparison.

The link: https://www.techempower.com/benchmarks/#section=test&runid=124fd2af-3030-4315-8876-e1db1fa91193&test=fortune&l=xan9xb-35r&o=3&c=3

joanhey commented 1 year ago

The symfony results are ready: image

So we'll show the json and single query:

Json image

Latency image

Single query image Latency image

The link to visualize the results: https://www.techempower.com/benchmarks/#section=test&runid=124fd2af-3030-4315-8876-e1db1fa91193&test=json&f=zik0zj-zik0zj-zik0zj-zik0zj-zik0zj-zik0zj-zik0zj-zik0zj-zik0zj-zik0zj-v2qiv3-zik0zj-zik0zj-cn3

joanhey commented 1 year ago

This benchmark is the most fair, as all the runtimes use the same framework and code.

javiereguiluz commented 1 year ago

Folks, we're closing this as "won't fix".

The reason is the same as explained here: https://github.com/symfony/symfony-docs/pull/18432#issuecomment-1597417283

We prefer to keep this article focused on the changes/tweaks you can do in your Symfony app and in some very specific PHP ini settings to improve performance.

Using servers that provide async features is important for some apps, but those projects will need to document how to integrate them with Symfony apps. Thanks for understanding!