Quercus
Sam Heisz
Caucho Technology
About Caucho
- Formed in 1998
- Initially javascript on the server
- Resin first released in 1999
- Quercus released in Decemeber, 2005
About Resin
- Web server
- Servlet, JSP, JPA, JMS, transactions
- Excellent performance
- Minimal configuration
- Static files faster than Apache (3x faster on 1k files, slightly faster for 64k files, slightly slower for 7 meg file)
- GPL
About Resin Professional
- Adds features to Resin typically needed in large production environments
- Clustering
- Distributed sessions
- Low level JNI for performance enhancements
- OpenSSL
About Quercus
- 100% java implementation
- Compiles PHP to java bytecode
- 100% reimplementation of the PHP libraries
Threading
- One process
- Thread based and thread safe
- Each request is allocated a thread
- Requests can use resources with a longer lifetime than the lifetime of the request
Compilation
- First request runs in interpreted mode
- Compilation occurs in background
- Optimizing
- Target is Java bytecode
Java and the JVM
- Bytecode, hotspot compiling to native code
- Garbage collection
- No pointer and buffer overruns
- Very large standard library
Quercus language
- PHP 5
- Unicode
- Black box testing of PHP implementation
- Ability to add closures
Quercus library
- Complete reimplementation of the PHP library
- Uses existing Java and Resin library whenever possible
- Database library uses Java database drivers and API
Use case: alternative PHP implementation
- Homogenous environment
- Excellent performance, 4 to 6x faster than mod_php, 10% faster than eaccelerator
- Database pooling
- Distributed sessions
Database connection pool
- Establishing a TCP connection is expensive, connection pooling
keeps connections open for subsequent requests
- Resin's connection pool is very robust
- Prepared statement cache
- Resin defaults are based on experience, little need to tune
Getting started
- Automatic recognition of .php files
- Database pooling is automatic
- No need for a compilation step, library is always available
Use case: extending PHP
- Quercus enables the use of Java objects and methods
- PHP programmer uses PHP semantics
- Allows targeted implementation or reimplementation of functionality
- Objects can exist beyond the lifetime of a single request
- Objects can be shared amongst requests
Use case: extending PHP
package example;
import com.caucho.quercus.module.AbstractQuercusModule;
public class HelloModule extends AbstractQuercusModule {
public static String hello_test(String message)
{
return "Hello, " + message;
}
}
Use case: extending PHP
WEB-INF/classes/META-INF/services/com.caucho.quercus.QuercusModule
example.HelloModule
Use case: extending PHP
<?php echo hello_test("World") ?>
Use case: using available Java functionality
- Java persistence architecture
- Spring framework
- JMS
- Transactions
Status
- Runs many PHP applications (i.e. MediaWiki, Drupal, Mantis)
- Primary task is to implement the complete library
- Unicode
- Out of beta in September
Summary
- 100% java implementation
- Compiles PHP to java bytecode
- 100% reimplementation of the PHP libraries
- Easy to extend PHP with Java
- Easy to integrate Java
- http://www.caucho.com