The good folks at Caucho were nice enough to send me a trial key for Quercus PHP Professional, so I gave it a spin this morning.
Quercus PHP is an implementation of PHP that runs on the JVM. The open source version runs in interpreted mode, while the Pro version compiles the PHP to Java byte code. The Pro version is not free, but costs $99 a year for a license.
Three Ways to Run Quercus PHP: As I see it, there are 3 ways to run Querucs, and your choice would depend on your use case and needs.
A) Compiled Mode - Compiled mode is only available in Quercus Pro ($99), but this will give you the fastest speed. The PHP script is compiled to Java classes, which yields not only fast PHP execution, but also leads to high performance integration with existing Java code. The only downside of this mode is that static strings are stored in the PermGen space. This is not necessarily a bad thing and this works the same way as JSPs, but it just something to be aware of when you are allocating space and re-deploying apps.
B) Interpreted Mode - In this mode, the PHP pages are interpreted at each request. This is still very fast, and very similar in speed to mod_php without APC. In this mode, the PHP file is cached, so there is no need to re-read the PHP from disk IO. You can adjust the size of the PHP page cache.
C) Interpreted with No Page Cache - This mode is the same as the above, except it removes the page cache of the PHP file. This mode is very similar to mod_php in that each PHP file is re-read from disk at each request. Most people would want a PHP page cache, but there are times when you may not want it because it will consume extra memory to keep those pages in the cache. On a memory restricted sites, with lots of different PHP pages in which each page (in of itself) is accessed rarely, you may want to disable the page cache.
Quick Performance Test
I ran a quick benchmark to see how the different Querucs modes perform. I grabbed a PHP benchmark from this site. This is a rather long running script, so it does not measure requests per second, but rather the time it takes to execute and entire script. Tomcat 7 was used as the Java server. I ran the scripts a number of times and averaged the results:
quercus compiled - 3247 ms
quercus interpreted - 7540 ms
quercus interpreted no page-cache -7798 ms
apache mod_php - 9088 ms
apache apc - 9159ms
As we can see Quercus in compiled mode is almost 3 times faster than Apache mod_php, and Quercus interpreted is a bit faster as well.
Since this is a long running script, the page cache did not really help the interpreted mode of Quercus. Similarly APC did not help mod_php, because the compile time is a small fraction of the running time.
We should not conclude too much from this quick test, but it seems to be in line with some of the results found on the official Quercus page.
No comments:
Post a Comment