Even though the PANTHEON server "stack" is already tuned to run Drupal as fast as possible, if your application doesn't know how to take advantage of the environment you won't see the breakthrough performance. This page describes the few key steps you need to take to insure that your Drupal application is ready to blaze.
Use Pressflow
Pressflow is the high performance distribution of Drupal. In addition to being optimized for PHP5 and MySQL5, it contains critical performance patches for Reverse-Proxy caching, which is one of the keys to PANTHEON's bulletproof performance under traffic spikes. A full comparison of Pressflow vs "Vanilla" Drupal is here.
To get started with Pressflow, can download a copy from the project page on Launchpad, or just use the version included with your PANTHEON server. It is 100% API compatible with Drupal core and there are only a few known edge cases of contrib modules which don't work under Pressflow, or break its caching ability.
Use Memcache, Varnish and ApacheSolr Modules
There are three important contributed modules for unlocking the potential of PANTHEON which you should install:
- Memcache allows high-performance "backend" caching for your site, which improves logged-in page performance. Be kind to your administrators and keep their pageviews snappy.
- ApacheSolr provides more relevant search results more quickly while placing less load on your server. Win/win/win. Just do it.
- Varnish the module allows your site to actively clear the reverse-proxy cache when things change, meaning you can have longer page lifetimes while still letting your users get fresh content.
These modules should be installed in the usual place for contribs: sites/all/modules.
Configure Your settings.php
The included "Mercury" install profile will do this for you, but assuming you're installing your own application with its own settings.php, you need to include the following block of code at the bottom:
# Varnish reverse proxy on localhost
$conf['reverse_proxy'] = TRUE;
$conf['reverse_proxy_addresses'] = array('127.0.0.1');
# Memcached configuration
$conf['cache_inc'] = './sites/all/modules/memcache/memcache.inc';
$conf['memcache_servers'] = array(
'127.0.0.1:11211' => 'default',
);
$conf['memcache_bins'] = array(
'cache' => 'default',
);
# Key Prefix: edit this for multisite use.
$conf['memcache_key_prefix'] = 'default';This will make sure your Drupal site is set up to respect the Varnish reverse proxy, and knows how to make use of the memcached back-end cache.
Configuration Within Drupal
Finally, there are two more pages to configure in your Drupal site. You need to point it at the bundled ApacheSolr search instance, and be sure your Drupal Performance settings are configured to make use of Varnish.
For ApacheSolr, visit admin/settings/apachesolr and configure as follows:
- Solr host name:
localhost - Solr port:
8180 - Solr path:
/default

Then visit the Performance settings at admin/settings/performance and configure as follows:
- Caching mode:
External - Page cache maximum age:
15 minutes(any non-zero value will work) - Page compression:
Disabled


Comments
Tomcat config
I'm confused on the Solr port setting in the Apache Solr module. I'm running Mercury 1.1b on Ubuntu Lucid, so maybe my config is supposed to be different? My site can only contact the Apache Solr server on port 8983. I took a look at /etc/tomcat6/server.xml - many settings are commented-out - the only port settings that are uncommented are:
<Server port="8005" shutdown="SHUTDOWN"><Connector port="8983" protocol="HTTP/1.1" address="127.0.0.1" connectionTimeout="20000" redirectPort="8443" maxThreads="6" minSpareThreads="3"/>
Is it correct to be using port 8983 in my case?
I'm tempted to uncomment
<!--<Connector executor="tomcatThreadPool"
port="8180" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
-->
and then change the connector port above to 8180, and the Apache Solr module setting to 8180, but figured I'd ask first.
re: Tomcat config
We have moved the tomcat port around in different versions of Pantheon as our thinking has changed - we've finally settled on 8983 which is the default port that the ApacheSolr module looks for.
Hope this helps,
Greg
--
Greg Coit
Systems Administrator
http://www.chapterthree.com
What about APC?
APC is set up on Mercury as per http://groups.drupal.org/node/70268 but does drupal need any configuration to talk to it (perhaps using the cacherouter module)?
Also, I see that you recommend the memcache module here, but Josh Koenig uses cacherouter and APC (no memcache) - http://www.chapterthree.com/blog/josh_koenig/project_mercury_preconfigur... - although that is an old post.
APC or memcache
As I now understand it, most sites will either use APC OR memcache, depending on the server setup (and could use both if necessary). If the website runs off one server, then APC is recommended. If the website is broken out onto more than one server, then memcache would be the better option (general rule-of-thumb).
This presentation helped me understand APC and memcache:
http://www.slideshare.net/FordAntiTrust/php-performance-with-apc-memcached
The cache router module allows the uses of a caching backend per database table. So as I understand it, Project Mercury installs both APC and memcache, and leaves it up to the administrator as to what technology to use when.
re: APC or memcache
As Aruna pointed out, both can be used since they cache different things, and Pantheon (Mercury) installs, configures and uses both by default.
Greg
--
Greg Coit
Systems Administrator
http://www.chapterthree.com
APC and memcache
APC and memcache are two completely different animals or fruit if you prefer to apples to oranges version. APC is an op-code cache, which caches the php-code while memcache caches data from the database. Both can be used very effectively together as they perform completely different actions.
Checking status?
Ah, ok - that makes sense - thanks for the distinction. I'm not sure why the cacherouter module seems to give the option of using APC to cache database tables, so clearly I'm not understanding something there.
Is there anything specific which must be enabled for drupal to talk to APC, or does APC just do its thing anyway?
Also, is there any way to see the statistics of APC and memcache (specifically, the hit rate)? I think I should be able to browse to apc.php somewhere to see the APC hit rate, but can't find that anywhere on the server. The only way I've found of seeing the memcache hit rate is enabling the memcache_admin module.
[Edit: found /usr/share/doc/php-apc/apc.php.gz - unzipped it and symlinked it to a place I could access online - and voila! Stats!]
You have to download
You have to download memcache.php separately.
http://svn.php.net/viewvc/pecl/memcache/trunk/memcache.php?view=co
Thanks again Greg for your
Thanks again Greg for your detailed and wonderful documentation.
After a few weeks of trying to understand the logistics and configure each individual piece, I have my Pantheon Mercury 1.1 Beta up and running now. The final piece that I was hunting down was why Apache SOLR could not connect to the server.
I found that it was using the module default port 8983 and /solr directory instead of port 8180 and /default.
Once, I spotted that I FINALLY have everything working on a Mercury 1.1 beta AMI with my data on an EBS volume!!!
Symetrik Design
Drupal Consulting
http://www.symetrkdesign.com