Boost is a page cache which works in a similar way to aggressive page caching in that it attempts to serve cached data without running the bootstrap. However, it is able to go one step further and avoid PHP being run as the redirect takes place in rewrite rules located in .htaccess. If the static file exists then it is served as the response. The end result is super fast response without running PHP or the bootstrap. This frees up the server to handle more requests from logged in users.
Boost is an attractive module because it is easy to install, has a lot of configuration options which give good control over cache building and invalidation. It is highly recommended.
The Varnish HTTP Accelerator Integration module integrates Drupal with Varnish, a reverse proxy which sits in front of Apache, PHP and Drupal. Varnish stores cached content in RAM and avoids the overhead of Apache and the Drupal bootstrap. As such it offers very high performance for anonymous users on cached pages and is the preferred option for many sites where scaling is paramount.
Varnish requires either a patch to core to add HTTP headers, PressFlow or Drupal 7. Most people are therefore running Varnish in conjunction with PressFlow.
Performance refers to the speed of the system. Basically, how long does it take to produce a page? Performance is a result of how long it takes to render a page (i) on the server and (ii) on the client side in the browser. It is important now to forget the client side of the equation as big gains can be made here if all else is running smoothly.
Scalability refers to the ability of the system to handle more requests. ie. as the load increases on a system how is it placed to handle it. What is the throughput of the site under heavy load? For anonymous users and logged in users? How stable is the system? Are there faults or errors? How many resources are consumed?
A Firefox addon which gives you an overview of the request/response cycle for a single web page. It provides a summary of all requests and offers suggestions as to how things can be improved. This tool is mainly used for optimising the rendering time of a page. See Drupal Page Rendering for more details on the client side. However, in terms of server side performance it does report the download time for the actual ‘doc’ requested which indicates how fast a page is being built on the server.
The Devel module is an essential tool to have on your dev machine. Devel is your first port of call on the server side when troubleshooting a site. You can use it to discover where problems are occurring before diving in to test further and debug. If you are suspicious that things aren’t quite right it can help you out with slow queries, slow pages and RAM consumption.
Drupal is a system which can be heavy on system resources, especially RAM, and so running it on shared hosting can be a challenge in some situations. In many cases a relatively minimal Drupal install will exceed maximum limits enforced by your hosting company. In these cases you will receive a polite letter telling you to fix your site or else you can upgrade to a dedicated server. Don’t worry. See Out of the box for some quick and easy wins on shared hosting plans.
Servers set up like this often have oversold the box you are hosted on and you will be at the mercy of other users who might be exceeding their allotment. Your performance will be adversely affected in these cases. YMMV.
The major downside of shared servers is the limited control you have over the hosting environment, leaving you with relatively few options to improve performance. Luckily Drupal has some handy features built in which make it possible to improve speed, memory and CPU. These are dealt with in more detail below.
Drupal’s modular system means that pages can have a large number of CSS and JS includes which results in a lot of client server communication – slowing the page draw time down. The problem can be alleviated by merging the files and then compressing them. This results in less includes and faster downloads. Up to 90% of download time can be attributed to downloading CSS, JS and images so it makes sense to aggregate and compress if possible.
Opcode caches cache the compiled form of a PHP script in shared memory to avoid the overhead of parsing and compiling the code every time the script runs. This saves RAM and reduces script execution time.
Enter the Apache Lucene project and Apache Solr.
Another option for those users looking to switch away from the in-built search is Google Custom Search – a search service offered by Google where Google indexes your data and stores the results on their servers. You are able to search the data via a simple form on your site. Google Custom Search is free for individuals, who don’t mind ads with their results, with a business version starting at $100 pa. The Google Custom Search Module integrates it into Drupal by providing a block with the form.
Pressflow is a distribution which attempts to bring many of the improvements discussed above (SQL improvements, Varnish) into a single package. Pressflow is a standard Drupal install which has had its core modified to fix bottlenecks and facilitate the use of advanced caching features. FourKitchens don’t regard Pressflow as a fork since many of the initiatives found in Pressflow are contributed back into the development of the head of Drupal.
So long as you haven’t hacked core yourself then using Pressflow is a simple matter of swapping out core drupal and replacing it with Pressflow.
In a nutshell Pressflow allows the following:
Project Mercury is an innovative project from Chapter Three which wraps up a tricked out PressFlow installation in to a preconfigured Amazon Machine Image (AMI) for use on Amazon EC2 instances.
The goal of this project is to make Drupal as fast as possible for as many people as possible. To that end, we are developing a pre-built Amazon Machine Image (AMI) which will allow anyone with an Amazon Web Services account to spin up an EC2 instance and see how all this works in real-time. The ultimate goal is a production-ready release that can be used for deploying real websites.
ab is the most commonly used benchmarking tool in the community. It shows you have many requests per second your site is capable of serving. Concurrency can be set to 1 to get end to end speed results or increased to get a more realistic load for your site. Look to the “failed requests” and “request per second” results.
In order to test the speed of a single page, turn off page caching and run ab with concurrency of one to get a baseline.
ab -n 1000 -c 1 http://drupal6/node/1
The Out of The Box section covered the inbuilt CSS and JS aggregation and file compression. The use of “combined files” is a significant factor in Drupal’s relatively good score in the YSlow tests. Make sure you have this enabled.
In the past it has been easy to not even consider mobile when designing a site or an application. However, there are so many compelling reasons these days to treat your mobile site as a key component of your web strategy. Mobile devices are becoming increasingly popular, more of your users will be accessing your site through a phone or tablet. They will expect a good experience from your site or else will not return. Watching a user attempt to browse your unoptimised desktop app on a mobile device is an embarrassing experience for you and frustrating for the user.
REST defines the architecture of the World Wide Web. One of the principles of REST is that a single URI represents a resource and that resource is conceptually different from the representations returned to the client.
We’ve just seen that serving different representations from a single URI is a good thing from many perspectives: mobile first, progressive enhancement, REST and SEO. However, there is one reason why we may we may decide to go down the path of using two domains instead of one: caching.
Caching mechanisms, such as Drupal Core and Boost, used the fully qualified domain name of a URI to determine caching keys. This allows the cache to quickly serve content to different clients without knowing the criteria which decides the representation received by the client, ie. the cache just has to know about the URI, it doesn’t need to decipher the user agent. Currently, if different representations are served for the same resource then the cache will likely become populated with a mix of different representations, leading to chaos. For this reason it is generally accepted that having a separate mobile site on a sub domain is a good way to go. ie. we would have two sites:
This article is a followup on how to configure memcache for Drupal, and how multiple bins help with performance.
Each bin in memcached correspond to one or more cache table in Drupal.
To do this, we first setup a start script for memcache that would start each bin with the correct size. This would go into /usr/local/bin/memcache.sh:
Wondering why your views run so slow? Why after switching to InnoDB, MySQL isn't running any better? This module has the answers!
It will show what CCK columns get used in a view filter or relationship and give you the option to add an index on it so the views query will run faster. Also can add indexes to core modules that could use one.
Drupal's block system allows you to place content in specific theme regions. But beware: even if you do not output a block in your theme, it will still be generated by the Drupal stack! That's because any enabled block's generation is determined by the block's visibility settings, not by the theme's region output.
This is disabled by default, but double-check to make sure. Often theme developers activate this feature to test their developments. But on live production sites this setting should be turned off at all times. Find the setting via Site Building > Themes > Settings and then click on your Theme to find the setting.
Drupal's statistics module has a disadvantage: extra MySQL queries per page load. Even when using the Boost module, boost_stats.php can still call these MySQL queries. Of course, it is up to you whether you need these Drupal stats. Most people will use Google Analytics as an alternative.
Other alternatives are server tools like Munin or Cacti.
Often overlooked by Drupal beginners, but still worth mentioning: do not forget to enable core caching at Administer > Site Configuration > Performance (/admin/settings/performance). To avoid issues with Drupal modules, simply select Cache Mode: Normal. And enable Page Compression.
Several Drupal modules bring their own caching system and caching tables. For example: Views, Panels and SWF Tools. Each have their own configuration options. On production servers, it is wise to enable them.
ImageCache is a module that can generate image thumbnails on the fly, to exactly fit your dimensions. The thumbnails is only generate once, so should not influence performance. The benefit however is to the end user: visitors will download smaller images instead of the full unscaled version.
Drupal's core caching system allows to set minimum cache lifetimes. This means content will not be refreshed until after a certain time. For example, on busy sites, you would set the Minimum Cache Life to 1 hour. That means visitors do not see changes on your site more often than 1 hour. But it greatly helps to improve cache-efficiency and reduces your server load.