Speeding up the snail
Marcus Deglos
and making Drupal scale
Who is Marcus?
Software engineer
with Ibuildings
Drupal contributor
PADI scuba diving
instructor
The problem with frameworks
The cost of the
framework:
- include files
- function calls
- database queries
So why use Drupal?
• Quicker to develop
• Easier to maintain
Turbo-charging your site
Optimising the stackTuning
Drupal
Adding hardware
Benchmarks
Optimising the stack
• Apache
• PHP
• MySQL
• APC extension
• Varnish
Apache
• Pre-fork vs Worker
mode
• Number of servers /
clients
• Impact of .htaccess
/ AllowOverride
• Impact of SuExec
Optimising the stack
PHP
• CGI vs Apache
Module vc FastCGI
• php.ini:
– Memory limit -
choose for stability
– register_long_
arrays
Optimising the stack
Database
• Optimising the database
– Monitoring with the slow query log
– Add (and remove) indices based on usage
– Consider table types: MYISAM vs INNODB
• Optimising the service
– Custom compilation
– Configuring my.cnf
• Consider your hardware
Optimising the stack
APC
• APC is an op-code
cache
• Install and forget?
• Monitor APC use
• APC tuning
– APC memory usage
– APC stat: checks if
files are modified
– APC filters
Optimising the stack
Varnish
• Varnish is an HTTP
accelerator
• Requires D7,
Pressflow, or a
patch to Drupal
core
• New mindset for
personalising
content - think ESI
Optimising the stack
Tuning Drupal
• Drupal page
cache
• Optimise JS /
CSS
• Memcached
• Using the Drupal
cache
Tuning Drupal
• admin/settings/performance
• Page caching improves performance for
anonymous users
• CSS and JS aggregation improves front-end
performance
Admin : performance settings
Tuning Drupal
Memcached
• Direct replacement for Drupal’s DB cache
• To setup:
– Install the Drupal module
– Configure settings.php
– Install the memcached daemon
– Install the PECL extension
• Minimal tuning (multiple cache ‘bins’)
Tuning Drupal
Using cache_get and cache_set
• Use a static cache for simple queries
static $foo = null;
• Use cache_get and cache_set for
complex objects:
– Multiple DB queries
– Slow remote resources (e.g. SOAP)
Adding hardware
• Separate the web server, database
server and HTTP accelerator onto their
own dedicated hardware
• Horizontal scaling: double the hardware
= double the performance?
• Hunt the bottleneck
• Scale with the cloud - Project Mercury
Benchmarking
• ab
• Jmeter
• Online services
Real world performance
Real world performance
Page cache
Real world performance
Memcache
Real world performance
APC
Real world performance
Varnish
Real world performance
Summary
• Page cache: 2x - 8x
• Memcache: 2.5x
• APC: 1x - 2x
• Varnish: 50x ?
Final thoughts
• Off the shelf :
Pressflow, Zend
Community
Server
• Quick wins:
– Page cache
– Memcache
– APC
– Varnish
That’s all folks!
Image attribution - CC via Flickr
• SNAIL (nutmeg66)
http://www.flickr.com/photos/rachel_s/29060
95941/
• SCUBA - FISH SCHOOL (tobze)
http://www.flickr.com/photos/tobze/2137899
342/
• BALL AND CHAIN (Fred Dawson)
http://www.flickr.com/photos/fwp-
dawson/520311773/
• SPOILER (icathing)
http://www.flickr.com/photos/icathing/26603
225/
• SERVER RACK (Jamison_Judd)
http://www.flickr.com/photos/jamisonjudd/24
33102356/
• GRAPH (tracer.ca)
http://www.flickr.com/photos/tracer/3249533
12/
• STACK (Wonderlane)
http://www.flickr.com/photos/wonderlane/23
63603984/
• TUNING (Crashmaster007)
http://www.flickr.com/photos/crashmaster/33
44052447/
• ROAD END (Joseph Hatfield)
http://www.flickr.com/photos/jhat/218880745
0/
• TORTOISE NAP (MaestroBen)
http://www.flickr.com/photos/maestroben/36
9200383/
• CAMERA (Burnt Pixel)
http://www.flickr.com/photos/keithwj/365098
384/
• QUESTIONS (Stefan Baudy)
http://www.flickr.com/photos/-
bast-/349497988/
• SERVER FARM (sugree)
http://www.flickr.com/photos/sugree/302464
0027/
• CAT (fofurasfelinas)
http://www.flickr.com/photos/fofurasfelinas/1
297744859/
Thanks for coming!
Rate this talk
http://joind.in/620
Download slides
from slideshare
@manarth

Speeding Up The Snail

  • 1.
    Speeding up thesnail Marcus Deglos and making Drupal scale
  • 2.
    Who is Marcus? Softwareengineer with Ibuildings Drupal contributor PADI scuba diving instructor
  • 3.
    The problem withframeworks The cost of the framework: - include files - function calls - database queries
  • 4.
    So why useDrupal? • Quicker to develop • Easier to maintain
  • 5.
    Turbo-charging your site Optimisingthe stackTuning Drupal Adding hardware Benchmarks
  • 6.
    Optimising the stack •Apache • PHP • MySQL • APC extension • Varnish
  • 7.
    Apache • Pre-fork vsWorker mode • Number of servers / clients • Impact of .htaccess / AllowOverride • Impact of SuExec Optimising the stack
  • 8.
    PHP • CGI vsApache Module vc FastCGI • php.ini: – Memory limit - choose for stability – register_long_ arrays Optimising the stack
  • 9.
    Database • Optimising thedatabase – Monitoring with the slow query log – Add (and remove) indices based on usage – Consider table types: MYISAM vs INNODB • Optimising the service – Custom compilation – Configuring my.cnf • Consider your hardware Optimising the stack
  • 10.
    APC • APC isan op-code cache • Install and forget? • Monitor APC use • APC tuning – APC memory usage – APC stat: checks if files are modified – APC filters Optimising the stack
  • 11.
    Varnish • Varnish isan HTTP accelerator • Requires D7, Pressflow, or a patch to Drupal core • New mindset for personalising content - think ESI Optimising the stack
  • 12.
    Tuning Drupal • Drupalpage cache • Optimise JS / CSS • Memcached • Using the Drupal cache
  • 13.
    Tuning Drupal • admin/settings/performance •Page caching improves performance for anonymous users • CSS and JS aggregation improves front-end performance Admin : performance settings
  • 14.
    Tuning Drupal Memcached • Directreplacement for Drupal’s DB cache • To setup: – Install the Drupal module – Configure settings.php – Install the memcached daemon – Install the PECL extension • Minimal tuning (multiple cache ‘bins’)
  • 15.
    Tuning Drupal Using cache_getand cache_set • Use a static cache for simple queries static $foo = null; • Use cache_get and cache_set for complex objects: – Multiple DB queries – Slow remote resources (e.g. SOAP)
  • 16.
    Adding hardware • Separatethe web server, database server and HTTP accelerator onto their own dedicated hardware • Horizontal scaling: double the hardware = double the performance? • Hunt the bottleneck • Scale with the cloud - Project Mercury
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
    Real world performance Summary •Page cache: 2x - 8x • Memcache: 2.5x • APC: 1x - 2x • Varnish: 50x ?
  • 24.
    Final thoughts • Offthe shelf : Pressflow, Zend Community Server • Quick wins: – Page cache – Memcache – APC – Varnish
  • 25.
  • 26.
    Image attribution -CC via Flickr • SNAIL (nutmeg66) http://www.flickr.com/photos/rachel_s/29060 95941/ • SCUBA - FISH SCHOOL (tobze) http://www.flickr.com/photos/tobze/2137899 342/ • BALL AND CHAIN (Fred Dawson) http://www.flickr.com/photos/fwp- dawson/520311773/ • SPOILER (icathing) http://www.flickr.com/photos/icathing/26603 225/ • SERVER RACK (Jamison_Judd) http://www.flickr.com/photos/jamisonjudd/24 33102356/ • GRAPH (tracer.ca) http://www.flickr.com/photos/tracer/3249533 12/ • STACK (Wonderlane) http://www.flickr.com/photos/wonderlane/23 63603984/ • TUNING (Crashmaster007) http://www.flickr.com/photos/crashmaster/33 44052447/ • ROAD END (Joseph Hatfield) http://www.flickr.com/photos/jhat/218880745 0/ • TORTOISE NAP (MaestroBen) http://www.flickr.com/photos/maestroben/36 9200383/ • CAMERA (Burnt Pixel) http://www.flickr.com/photos/keithwj/365098 384/ • QUESTIONS (Stefan Baudy) http://www.flickr.com/photos/- bast-/349497988/ • SERVER FARM (sugree) http://www.flickr.com/photos/sugree/302464 0027/ • CAT (fofurasfelinas) http://www.flickr.com/photos/fofurasfelinas/1 297744859/
  • 27.
    Thanks for coming! Ratethis talk http://joind.in/620 Download slides from slideshare @manarth