Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

DominikH's avatar

Laravel Octane vs Laravel + PHP-FPM- performance

Hi guys, I am struggling with my very, not so specific use case. At the moment I have an application that is composed of around 30 microservices (auth, config, localization etc). Each of these MS is written in Lumen 10 and encapsulated in Docker Image. The application is served in Kubernetes so I have 2 containers in a Pod: NginX 1.20.1 PHP-FPM 8.2.2 + JIT (config set to: 1255) What I want is to migrate from Lumen to Laravel because of many reasons. When I migrated one of the MS to pure Laravel, from performance point of view, it was an catastrophe. More than 50% drop. I done all the usual performance optimalizations like: remove unused providers, cached config and routes etc. But still the performance was very low compare to Lumen. The internal structure of the code is very simple, it is just an I/O layer for database, so the application code is 100% the same. So what I did I tried to use Octane to improve speed. I used Swoole and OpenSwoole for my benchmark. After few days of playing around I encountered all the typical problems that people have: The application was very slow - fixed by remove --watch The application took lots of RAM - fixed by adding specific value to number of workers and task_workers etc. After fixing all the basic issues and usage of Octane::concurrently I was able to beat Lumens performance. I also have some Laravel projects (APIs) so what I did was that I migrated one of them to Laravel Octane + OpenSwoole. I done only the necessary changes like: laravel.com/docs/10.x/octane#configuration-repository-injection or laravel.com/docs/10.x/octane#container-injection or move all env() helper usage to config files and insted of env() helper use config() helper in controllers etc. I was very surprised that the application has much worse performance that the original one under PHP-FPM 8.2.2 + JIT. And I am not talking about some minor differences in miliseconds. So I wrote test case in Apache JMeter and the results are following (100 users, sequential):

Laravel + NginX + OpenSwoole Init call - 775 ms Avg - 3174 ms Top - 4059 ms

Laravel + NginX + PHP-FPM Init call - 338 ms Avg - 1400 ms Top - 1900 ms

The FPM and OpenSwoole configs are very similar regards to logical representation. For example: PHP-FPM pm = dynamic pm.max_children = 5 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 3 pm.process_idle_timeout = 10s;

OpenSwoole 'worker_num' => 5, 'reactor_num' => 5,

I know this is more of a OpenSwoole / Swoole question than Laravel but sill. Is anybody who has any idea why the same code from application (not configuration) perspective is slower on Octane than on normal PHP-FPM? Thank you very much for any advice. Of course the php.ini is the same.

0 likes
0 replies

Please or to participate in this conversation.