I am the first to admit I am not a PHP expert. I don’t have the same depth of PHP knowledge and experience than many others do. There has been a lot of discussion about PHPNG vs HHVM and which is faster. As I see it
- PHPNG is not here yet, so until then its interesting to watch but not going to change what I do today.
- HHVM is here today, but not guaranteed to be compatible across all extensions, and relying on it would tie you to a single vendor (Facebook) rather than a community.
Both are interesting. Both claim good gains with low effort. But if you are serious about getting a Magento site running faster, are they actually the most important question?
If I look at a large PHP application such as Magento, a lot of time seems to be taken as a part of the startup overheads. This includes getting the PHP code started (which is why op code caches etc help), but for an application like Magento there is also a lot of loading of configuration files after the code starts running that do not change between requests. For Magento 2 in particular there are class maps for auto-loaders, dependency injection configuration files, layout files, and so on.
I sometimes wonder if Magento 2 more clearly separated loading configuration files etc (and caching the results) from the processing of the current request (with dynamic data) whether more significant performance gains could be achieved than what PHPNG/HHVM offer. Sure, the code would have to be carefully written to make sure no “sensitive” data was accidentally cached around between requests. And you would have to watch memory usage more. But would it go faster?
I don’t know the answer – sounds like a bit of effort required to try it out. But looking around I see projects like ReactPHP that have a long running server that responds to multiple requests (so can cache data structures between requests). The article http://marcjschmidt.de/blog/2014/02/08/php-high-performance.html was particularly interesting. “As we can see, the react server with nginx as load balancer is over 15 times faster than old school PHP-FPM + APC”. I have no idea if Magento would achieve the same gain.
This is an interesting question to me. Is making PHP faster is actually the main way to improve performance and throughput of a large PHP based application? Or is it the web server model of starting a script from scratch per HTTP request that is the ultimate problem? The current model is certainly robust and easy to adopt, which is a real positive, but if you are serious about performance and scale is it enough? Or is it that if you want serious performance you need to think about a model where PHP code is kept running (in say an Actor based threading model) to avoid the startup overheads per request. The PHP code is there, pre-initialized, and waiting to process the next request.
Anyone got experience with this in PHP? Or does PHP leak memory so much (for example) that this approach is just not feasible in practice?