Geert Bevin recently experimented with clustering Drupal with Terracotta running on Caucho's Quercus, a Java implementation of PHP. While checking the reasons beind the complaint about the scalability of Drupal on PHP, Geert looked through the layer cache implementation and found developers use the database as a cache. Short of using memcached, PHP doesn't support preserving object state across requests; so this method is alright. But tunneling everything through the database is bound to create a bottleneck.
Quercus, the Java implementation of PHP that runs in Resin, has a module system that allows the creation of PHP functions in Java. Geert got down to seeign if Terracotta could be used together with Ehcache to replace Drupal's caching system with a more scalable solution. Geert has put together a prototype to improve the scalability of a PHP CMS by using JVM-level clustering, where Drupal is using Ehcache which is clustered through Terracotta, although "very hackishly due to non existent Resin support". The current state of things are:
- Resin launches another Java process that runs the actual web server, this means that resin.conf needs to be modified to actually use Terracotta with the servlet container.
- By default Resin replaces the system classloader. This seems to go into an endless loop when used with Terracotta. Geert didn't go through it step by step to find the exact cause yet though. But he has made a patch that disables this system classloader entirely, which seems to work. Some features of Resin are most probably disabled due to this, but he hasn't investigated what exactly though.
- Using Ehcache as a Quercus module and changing the Drupal cache handling makes it possible for Terracotta to cluster the Drupal cache entries.
A detailed set of instructions can be seen here.




