1) Performance
So, is actually Quercus faster than Zend? In some operations it is a bit faster, and in some operations it is a bit slower. In general, I would say that Quercus PHP has about the same performace as Zend PHP for most PHP requests. Quercus comes in 2 flavors, interpreted mode and compiled mode. The interpreted mode is (in my epxierence) roughly comparable to not using a code cache with Zend, while the compiled mode is comparable to using a code cache with Zend. See the following doc for an overview of Quercus performace.
While this does not seem like much of a "win" for Quercus, it is important to point out that Quercus is not slower for a standard PHP request. If Quercus were slower, the following points would be rather moot. However, Querucs is fast, and combinded with the following advantages, it is a platform to be considered for PHP devleopment.
2) PHP in the front, Java in the back
Different computer languages were written for different tasks. PHP was written as a web app language and excels at formatting data for the presentation layer. Java is great for creating data structures, algorithms, database connectivity, transactions, etc
The great thing about Quercus is it allows us to take advantage of both languages by using them seamlessly together: with PHP as the presentation of a Java based business tier. With Quercus, you can write your data structures and business logic with Java, which then passes the results to PHP to be formatted and sent to the client. This process is simple because Quercus PHP can seamlessly call Java objects/methods. Using the best parts of both languages, one can do some really cool stuff.
- Call Lucane, Hadoop, Cassandra (and more) directly from PHP.
- Create complex and fast data structures in Java, which are then queried and displayed with PHP.
- Application scope objects in PHP that are backed by Java objects.
- Utilize the rich PHP web templating, with the vast array of Java middle-ware libraries.
- Shared data structures between PHP and Java components of an application.
- Choose which parts of the application are best suited for PH P and/or Java
3) Database Connection Pooling.
One of the best features of Java is database connection pooling. Database connection pooling allows database connections to be managed by a pool that automatically grows and shrinks according to demand. Connection pools save resources because database connections do not need to be constantly created/destroyed which has considerable overhead, particularly when done over remote connections. Not only does this help the web layer, it also saves resources at the database layer because only a minimal amount of persistent connections need to be maintained.
Out of the box, Quercus allows the use of database pooling without having to change a line of php/mysql code! Moreover, one can use PHP to Java integration (see point #2) to access Java objeccts backed by JDBC connection pooling.
4) Scalable AJAX with PHP running on Java NIO
One of the problems with most setups of PHP is that there is one (thick) process attached to each request that blocks the process/thread until the response is sent. On the other hand, Java has the option of using NIO (non-blocking IO) in the Servlet container. This means that there is no longer a one to one ratio between requests and threads, but there can be many thousands of requests that are being severed by a small number of threads. This is particularly good for AJAX, because many of those connections will be waiting for the next request within a keep alive. By simply enabling an NIO connector, Quercus can scale to handle large number of non-blocking AJAX style requests in PHP. No reason to turn down those keep alives!
5) Scalable COMET with PHP via Servlet 3.0 Async
NIO's best friend is the Servlet 3.0 Asynchronous processing. Putting this two technologies together allows a highly scalable COMET style app. Servlet 3.0 Asychronous processing allows the requst thread to immedately return to the pool and allow another thread to handle the response. This allows a single thread to efficiently pipe messages to many listeners. Using this technology one can create scalable push notificaitons, chat rooms, and virtual worlds. While the above point (#4) is seamless to the PHP developer, creating COMET with PHP will require extra coding, but nothing more than calling a few Java classes (see point #2).
6) Improved Session Management.
The standard PHP implementation places all session data on the disk, which can be quite slow. Zend PHP does allow writing sessions to a database, however this requires quite a bit of work. One thing that Zend PHP cannot do is manage the sessions directly in memory.
On ther other hand, Java Servlet containers provide several configurable session options which can be easily taken advantage of with Quercus PHP, since sessions in Quercus are written on top of Java sessions. The following options require only a change in the xml file. Here are some options:
- Memory - the defualt of most servlet containers is to store the session objects in memory. This is very fast because it does not require disk access and serialization at every request.
- Memory to Disk - this option access the sessions from memory, but then serialized them to disk after a period of inactivity
- Memory to Database - smilar to above but backed by a database. This is great for distributed sessions.
7) Application Scope Objects
Because the standard implemenation of PHP is share nothing, sharing objects between processes requires a external resource: APC object cache, Memcache, or writing the object to disk. All these approaches share a common problems. First, the objects need to be serialized/serialized frequently. Second, there is no garnatee that two requests are referencing the same object. This can occur if one process retreives the object, and starts processing while another process has updated the object.
For Java Servlets, Application scope objects objects are trivial. Because they are kept in memory, cached objects do not need to be serialized and each servlet will always have a copy of the most recent object. Using a Java backed object in Quercus PHP, application scoped objects are simple. Ofcourse you could always serialize the object to disk/memccahe with Quercus just like you do with standard PHP, if that is what you desire.
Another option is to use the built in Quercus APC module. This module works just like the normal APC and it is seamless to the PHP developer.
No comments:
Post a Comment