Benchmarking Laravel with Swoole, FrankenPHP, RoadRunner, php-fpm, and ngx-php

preview_player
Показать описание
I've set up ngx-php to run Laravel example application in worker mode with Octane and then compared the performance with classic php-fpm and also other Octane drivers like FrankenPHP, Swoole, and RoadRunner.

The code and results are available here:
Рекомендации по теме
Комментарии
Автор

Raw PHP performance is only part of the story. In real-life apps, enabling HTTP/3, compressing responses with modern formats such as Zstandard or Brotli, and using Early Hints will usually have a bigger impact on performance. FrankenPHP supports all of this by default!

kdunglas
Автор

Thanks for the video
It's really interesting what modern ways of running php app exists nowdays and how fast & different they are
If you would have some extra time, it would be interesting to see if build-in optimizations would affect performance somehow.
- php-fpm pm.*
- jit
- opcache
- preload
- disabling circular reference collector (gc) - that's interesting one. It should be fine to have it disabled for php-fpm, but for other ways of running - not sure.

MrWancer
Автор

I'm sorry, but there are som extreme issues with your testing. I did a quick test on a 5 year old machine, and I'm getting 12K rps on the default Laravel landing page with Swoole. That's around 50x your results.

Here are some of the issues:
1. You're running on macos. That's not at all what people actually run their sites on. You might even be running on a different arch if your PC is ARM.
2. You're using docker. Docker does not have much overhead, normally. However, since you're on macos you're running docker in a VM, and the biggest issue is that you're using bind mounts. This isn't a issue on Linux, but on Windows and macos it's insanely slow. Move all your files into the container as part of the image, that helps.
3. You're probably just benchmarking sqlite as Laravel uses it for session storage by default. If you look at CPU usage during benchmarking you'll most likely see that your computer is mostly idle. Use something more realistic, like MariaDB or Redis, to reduce the storage bottleneck. CPU usage should be 100 % if you're benchmarking PHP execution.
4. You might not be running artisan optimize or optimizing the composer autoloader. Maybe you're also running Laravel in debug mode?

All these things are things that are normal to do for an actual website, so the number you're getting are very unrealistic. Getting realistic numbers needs to be done on a realistic setup. Benchmarking and profiling software on a different OS(or arch) to the one that will be used in prod can give very wrong.

theshinyplayer
Автор

Excellent video, php-fpm top) we are waiting for more content from you

CutCodeRu
Автор

Bro, me noobie running a blog with artisan command in production. I am digging into php-fpm but can you tell me what exactly the reason we should not run artisan command in production?

ripplesr
Автор

I'd like to see this vid with symfony now :)

shkabo
Автор

Where does Apache fit in the benchmark?

medilies
Автор

is opcache enabled when running php-fpm?

midgardresident
Автор

As for me FrankenPHP is cool but it's not ready to use in production/ Swoole looks like more stable solution.

kruhlyk_ua
Автор

What about ecosystem ? swoole has upd, tcp, websockets integrated and on my opinion its a killer feature combined with prety nice performance with easy setup and run. Swoole is my choice. But your benchmark interesting too. Feed for thought.

ROX
Автор

is ngx-phpworker similar to workerman/adapterman ?

abdellahb
Автор

I'd prefer frankenphp worker mode

budipriyatno
Автор

`Hello world` test is a test that will never be applicable to a real world app. Swoole has coroutines, async db queries, workers for tasks. What result will ngx-php show when querying the database, while swoole continues to handle other connections while the database query is running? (Unfortunately, this is not implemented in Laravel Octane)

seqgame
Автор

You have memory leaks because of Laravel. It is not properly implemented for long running tasks. You need to use octane to properly clear the state.

lemeshenko
Автор

or you can use golang or if dont like static types langs you can simply use nodejs

zhitoobit
Автор

Nobody cares about an empty laravel framework. In the real world you have a couple of database and synchronous http requests what makes your application boot time negligible. Much more interesting is the ability to make parallel requests asynchronously, what can speed up your real world requests dramatically. And Swoole is the only option. It looks really promising, I have to play with it a bit.

dimitrikalinin
Автор

the best you can get is 300 rps? PHP is great, just not the performance!

raiyansarker
Автор

If someone chooses Laravel it is because they have given up on performance.

tarilonte
Автор

Nonsense ! no context no logic no nothing just switching between those webservers do NOTHING

expatExperience
visit shbcf.ru