High Performance Drupal

36
High Performance Drupal Making Your Site Fast Fast Fast

description

Presentation from BADCamp 2009 on high performance Drupal: how to make your website fast and scalable.

Transcript of High Performance Drupal

Page 1: High Performance Drupal

High Performance DrupalMaking Your Site Fast Fast Fast

Page 2: High Performance Drupal

Drupal Is Powerful

Page 3: High Performance Drupal

Drupal is Slow

Page 4: High Performance Drupal

Databases are Slow

Page 5: High Performance Drupal

PHP Is Slow

Page 6: High Performance Drupal

Consumer-Grade Networks Are Slow

Page 7: High Performance Drupal

Increasing Speed Means Diving Less Deeply Into The Stack

Page 8: High Performance Drupal

Fast Is Making Fewer Requests From Faster Sources

Page 9: High Performance Drupal

The Life Of A Pageload

• Browser Request

• Browser Cache?

• Network Request

• Server Response

• Associated Assets (back to top)

Page 10: High Performance Drupal

Optimizing For The Browser

• Make Your HTML/CSS Images Efficient

• Use CSS/JS Aggregation

• Use a CDN

• Yslow is good for profiling this

Page 11: High Performance Drupal

Optimizing Server Response

• Reverse Proxy/Drupal Page Cache

• PHP OpCode Cache

• Drupal System Cache

Page 12: High Performance Drupal

Reverse-Proxies Are Very Fast

Page 13: High Performance Drupal

Faster Than Apache

Page 14: High Performance Drupal

Much Faster Than Drupal

Page 15: High Performance Drupal

Don’t Bother Your Power Tools With Simple Tasks

Page 16: High Performance Drupal

Implementing Varnish

• Use Pressflow

• Implement A Simple VCL Based On Sessions

• Enable Aggressive Caching

• Enjoy, Experiment, Excel

Page 17: High Performance Drupal

OpCode Caching Keeps Drupal Loaded In Memory

Page 18: High Performance Drupal

Don’t Touch The Disk

Page 19: High Performance Drupal

Don’t Load Up Apache Threads With Copies of Drupal

Page 20: High Performance Drupal

Implementing APC

• The Biggest/Cheapest Win

• Install via apt-get, yum, or pecl

• Monitor with apc.php

• Lots of modules? Bump the SHM size

• Enable apc.stat=0 with caution

Page 21: High Performance Drupal

Drupal Freezes It’s Code Before Launch

Page 22: High Performance Drupal

Most Real-World Scaling Information Comes After Release

Page 23: High Performance Drupal

Drupal Supports A Crazy Array Of Use Cases

Page 24: High Performance Drupal

$5/month Shared Hosting Is Not High Performance

Page 25: High Performance Drupal

Pressflow

• “Pressflow Makes Drupal Scale”

• Drop-in Replacement For Core

• Backports many Drupal 7 features

• PHP 5.x/MySQL 5.x Required

• Enables robust reverse-proxy, mysql replication and more

• Runs drupal.org and many other high-performance sites

Page 26: High Performance Drupal

Drupal Has A Cache And That Is Good

Page 27: High Performance Drupal

But... Drupal’s Cache Is In The Database

Page 28: High Performance Drupal

And Serialized.

Page 29: High Performance Drupal

That Works Anywhere, But Is Both Slow and Expensive

Page 30: High Performance Drupal

CacheRouter

• Use settings.php to plug in cacherouter instead of /includes/cache.inc

• Pick your poison: APC, XCache, Memcached, Filesystem, or classic db caching.

• Change caches per table.

• Vital for high-speed logged-in pageloads.

Page 31: High Performance Drupal

Coming Soon: Advcache

• Cache Nodes, Users, Taxonomy Terms and other common objects via cacherouter.

• Extends the notion of drupal’s static cache to whole objects.

• Still in development, but if you’re into writing patches...

Page 32: High Performance Drupal

Other Tips

• Search is among the slowest and most expensive queries. Use Solr instead.

• InnoDB can help with locking in MySQL

• Hardware is faster and often more cost effective than code cleanup.

• Monitor load and scale ahead of problems.

Page 33: High Performance Drupal

Benchmarking/Profiling

• Cachegrind to profile code.

• Jmeter to simulate load.

• Slow Query logs, cactai, etc.

Page 34: High Performance Drupal

Vertical/Horizntal Scaling

• Start with all services you need.

• Separate services into layers.

• Add more servers at each layer as needed.

• Shameless plug: Project Mercury: http://getpantheon.com

Page 35: High Performance Drupal
Page 36: High Performance Drupal

More Resources

• http://groups.drupal.org/high-performance

• http://pressflow.org

• http://tag1consulting.com

• http://2bits.com

• http://getpantheon.com