Originally posted by ddriver
View Post
* PHP by default serves requests by checking cache, checks files, loading all the classes, makes connections, runs the requests, returns the result and then drops all the work it did.
* Repeat all the steps above!!!!
When you compare a language like Go, those fancy benchmarks looks great ( aka 10X ) performance difference for micro-services etc. But this is literally comparing apples vs aliens.
The main reason Go as a compile language is "faster", is because it does this:
* Go: You start the executable, it starts it http server, makes connections, gets request, return result, gets request, return result, gets request, return result, ...
Notice how it does not reload everything? Because unlike default PHP, it does not do fire-and-forget.
If you take PHP and install Swoole or Workerman or whatever solution, it does this:
* PHP: You start the executable, it starts it http server, makes connections, gets request, return result, gets request, return result, gets request, return result, ...
All of a sudden, PHP is the same speed as Go, pushing out 10 times as many requests then before.
Where Go has a advantage, is if the code is highly mathematical. A spot that PHP 8.0 is heavily reducing with the JIT. While it will never reach Go levels on pure mathematical code ( PHP loses speed because of its user friendly features and hated features by compiler guys ) but for Web content and Micro-Services, PHP can easily competed these days with Go and other languages. You just need to know what to use.
Do not belief me?
https://www.techempower.com/benchmar...l=zg21hb-f&a=2
Notice how Go and PHP results are darn close and at worst 3x ( echo world ). Native PHP results are bad because of the issues mentioned above.
Only people with out of data information, do do not know how PHP works and make senseless comparisons with compile language, despite both by default using a totally different approach to serving data. Its like all those fools who keep spewing "PHP Sucks" with examples from the PHP 5.X days, that are long time invalid...
There has been some pressure on the PHP developers to finally upgrade the build in HTTP server to allow this type of "Go like" behavior by default.
Leave a comment: