Veröffentlicht am 3. Februar 2010 (vor 6 Tagen)
A lot has already be speculated about what percentage of existing PHP users would benefit from using HipHop. The numbers seem to range somwhere between 0% and 100%. I will not try a guess myself, but rather try to shed some light on some the most important prerequisites I think there are for a company to benefit from HipHop.
As of today, HipHop does not support PHP 5.3 features, and does not support certain PHP 5.2 features like eval(). Let aside the fact that eval should be considered evil and not be used altogether, you cannot "just write" PHP code and assume that it works with HipHop. Thus, implementing and enforcing coding guidelines will become much more important than it is even today.
There will always be a functional gap between HipHop and PHP, since PHP evolves and introduces new features that HipHop must adopt. So HipHop will always lag a little behind. This is usually not a problem unless you need to use certain features of the latest PHP version. So coding for HipHop means defensive coding.
HipHop executes PHP code bypassing the Zend Engine, so there is no guarantee that a program will behave exactly alike on PHP and HipHop. More and better automated unit and integration tests will be required to allow you to compare the results on PHP and on HipHop, and determine whether deviations are to be interpreted as a bug, or can be tolerated.
It is unrealistic to assume that a larger code base currently running on PHP will produce exactly the same results on HipHop. Results can differ for example due to different implicit sort orders. Even if automated tests are in place to compare results of PHP and HipHop, those differences must be accounted for in the testsuites. This requires a flexible software architecture that allows for dependency injection and mocking of objects.
On the longer run, C++ skills and development tools will be required. Existing PHP tools like xdebug are not available on HipHop, since there is no PHP involved when the software is being executed on a production server. Any debugging at the level of C++ code will be hard, if not impossible, to relate to PHP code. Judging by my own C++ skills, debugging would just not be an option altogether. I fear this will hold true for the vast majority of PHP development teams.
Since PHP runs on virtually any web server, you can deploy the same script on an Intel or AMD processor, or even to a different operating system. PHP code, at least when written carefully, runs pretty much abstracted from the actual system environment.
HipHop produces C++ code that will be compiled into highly optimized machine language. Suddenly, processor architecture matters. Software cannot be compiled just once, but must be compiled and optimized separately for a each target architecture. With HipHop, you will either have to unify the architecture of your servers, or set up a compile farm that cross-compiles for the different server architectures. Compiling larger code bases can take a considerable amount of time, and every single software change forces you to recompile the software.
Deploying just a few modified PHP scripts is no longer an option, a large, monolithic binary has to be deployed. More complex build and deployment processes must be established. Apache or Lighty are no longer an option, HipHop comes with its own web server. All load-balancing, caching, proxying, URL-rewriting that currently takes place in the web servers must be adapted.
HipHop will reduce the load on your systems, but that does not necessarily mean shorter answering times for the users of your website. This is because I/O is where the action is. Accessing disks or the network is very slow compared to executing PHP code. As a matter of fact, when executing a PHP application, the computer on the average spends most of the answering time waiting for data to be loaded from external resources, or being stored to external resources.
Even if HipHop handles I/O faster than PHP does, it will not make your disks or your network faster. So all you can expect from using HipHop is the ability to serve more concurrent requests with the same amount of servers (or using fewer servers to serve the same amount of requests, of course). The most interesting question is whether your I/O backends, being the overall performance bottlenecks anyway, can keep up with serving an increased amount of concurrent requests. You might just have shifted your scaling problem. To determine the right scaling measures, a decent amount of thorough code profiling is required, and you might as well have to rethink your software architecture.
Turns out, you might have to walk a long road until you can even start to dance the HipHop.
Tags: PHP, Facebook, HipHop, Ilia Alshanetsky, C++
Kommentare bitte per E-Mail.
Diplom-Informatiker Stefan Priebsch ist IT-Consultant, Trainer und Spezialist für die Entwicklung PHP-basierter Software.
Er ist Autor zahlreicher Bücher und Fachartikel über verschiedene Aspekte des Software-Lebenszyklus und spricht regelmäßig auf internationalen IT-Konferenzen.
Stefan Priebsch ist verheiratet und lebt und arbeitet in Wolfratshausen bei München. Er ist Mitgründer und Principal Consultant von thePHP.cc.
"Stefan has proven himself to be very knowledgeable, reliable, and easy to work with. His professionalism and attention to detail make him an editor's dream. I would highly recommend Stefan not only as an author, but also as a PHP developer, a consultant and a speaker, as he excels in these capacities as well."
--Elizabeth Naramore, php|architect
Der erste deutsche PHP Summit - powered by thePHP.cc - ist eine neue und
einzigartige Veranstaltung, die alle wichtigen Themen rund um die
Software-Entwicklung mit PHP in kompakter Form vermittelt.
(vor 8 Tagen)
» Blog-Eintrag lesen
Want to learn how to turn bad code into good code, and master the full software development cycle, from good design to successful deployment of PHP applications?
(vor 10 Tagen)
» Blog-Eintrag lesen
Es ist nicht immer klug, auf andere zu hören. Aber auf sich selbst sollte man
eigentlich schon hören. Das habe ich jetzt auch wieder lernen müssen.
(vor 30 Tagen)
» Blog-Eintrag lesen
Feedback Testing Conference QA Book Book PHP 5.3 Slides Migration Selenium PHP Blog MVC Arne Blankerts Relaunch CodeWorks09 Workshop hack U.S.A. OOP Quotes Lifecycle Chicago Design Patterns Webcast tek09 thePHP.cc Montreal Training Sebastian Bergmann Derick Rethans Slideshare fail MTA PHP Quebec 09 Magento Wordpress Atlanta Canada CRAP Presentation
@ralphschindler Or 42, depending on the question ;-) (vor 4 Tagen)
» Tweet lesen
@PierreJoye Zoe's busy at IBM, I'm busy preparing to become a daddy. So currently no progress with run-tests, unfortunately. (vor 5 Tagen)
» Tweet lesen
@ramsey Do you really need a conference as an excuse to visit Munich and have a beer? ;-) Otherwise, for the conference part, I fully agree (vor 5 Tagen)
» Tweet lesen