Everyday there are a lot of trendy technologies and tools out there, when it comes to PHP the trendy concept is "Async PHP" where there are some packages/extensions tells us that it provides a truly async functionality but in php, that is right, but there is something more important we didn't answer, which is "What is the actual problem we're trying to solve here?".
You're trying to solve performance issues by re-inventing the wheel, PHP-FPM has already been built years ago to provide a FastCGI process manager that manage PHP processes and gives you a lot of scalability options, you can easily scale it to handle multiple requests at a time by configuring how many processes you want to be available, which we can map it to "workers", it also enables you to configure the maximum time a worker takes to finish a request, if it exceeded that time, it would be terminated instantly!, as well a lot of security problems it solves.
If your request life cycle is designed to take 1 second, then it will take 1 second, it isn't a language only problem it is about how you're writing the control flows, database queries, external network calls, ... etc.
Just try to write a "Hello World" in both PHP and nodejs without any framework, you will find that the're very close to each other, this post isn't about benchmarking but it is about PHP-FPM only.
All new tools claims the async world, already do the above mentioned concepts already but in another way which doesn't solve the main problem "the community and the ecosystem" which isn't a problem at all!
But you may find another problem which is "simplcify" how to simplify the production runtime, I don't want to write a nginx.conf, php-fpm.ini and php.ini in addition to my original application configurations, I'll say, "You're right", that's why there are many tools out there to do so instead of you, something like PHOO which is being used and tested in production, is doing a lot of magic for you:
- Configures, spawns and control the PHP-FPM process transparently for you.
- Offloads the HTTP requests and proxies them to the FastCGI workers handled by the FPM process.
- Serves static files for you.
All what you need is phoo serve -r ./public
to serve your laravel project without any extra lines of configurations.
Let's back to basics, any old stuff isn't build for old days, but it is proven to work over years/decades, so let's make use of the old but gold tools.
The above words are just my personal opinion which doesn't mean "PHP is the best" but it means that each tool is designed to do somethings better than others, and thinking about the main problem you're trying to solve is the main problem you should focus on, as not all the apps/websites out there focuses on 1ms response time only! that's why the productive frameworks exist, if you need raw performance go and write everything from scratch.
Top comments (0)