Whenever you’re ready...
 Performance & Scalability with Drupal




                                     !"#$%&#'()
Who the hell is this guy?


• I run Wiredcraft (http://wiredcraft.com)
• We build (serious) Web and mobile solutions
  using Open Source technologies

• We work with the United Nations, CNN,
  Nvidia...



                                          !"#$%&#'()
What’s the deal?

• Drupal is;
 • flexible & extensible
 • slow  as hell




• We want to;
 • deliver the content quickly to the user
 • optimize the use of backend resources
                                        !"#$%&#'()
How do we do that?


• Analyze the bottleneck
• Adapt the back-end and/or front-end
• Test
• Repeat


                                        !"#$%&#'()
Now a few advices...


• Add complexity incrementally
• Scale vertically first
• Focus on users not system administrators
• Optimizing your code is a huge part of the
  equation



                                         !"#$%&#'()
Analyze the bottleneck

• Pimp up your shell skills
• Problem: Network? Disk? CPU? Memory?
• Source: Web server? App server? DB?
• Caching is not magic; it adds complexity
• For the long run, consider monitoring;
  Zabbix, Cacti, Nagios, Munin...



                                        !"#$%&#'()
Web server

• Clean up your configuration (MPM,
  MaxClients, MaxRequestsPerChild,
  KeepAlive...)

• Remove unnecessary modules
• Consider switching to NGINX
• Stress test (Apache Benchmark)
• Scale horizontally; load balancer (HAproxy)
                                         !"#$%&#'()
App server


• Clean up your configurationand add slow logs if possible




• Remove unnecessary modules
• Consider switching to CGI; PHP-FPM or
  FastCGI

• Add an opcode; XCache, eAccelerator or APC

                                                       !"#$%&#'()
Database server


• Clean up your configuration   and add slow logs




• Add caching; Memcache
• Switch from MyISAM to InnoDB
• Scale horizontally; Master/Slave replication


                                                   !"#$%&#'()
What is Pressflow?


• Patched version of Drupalfor performance purpose




• Runs Drupal.org
• Only works with PHP5 and MySQL
• Supports M/S replication and reverse-proxy


                                                     !"#$%&#'()
Other optimizations...

• Views caching
• Block caching (Block Cache Alter module)
• Reverse proxy (Varnish) or file caching
  (Boost)

• Add a full text search engine; Solr, Sphinx,
  Elastic Search... Plenty of modules; Search
  API module, Searchlight...


                                          !"#$%&#'()
And then some more


• Authenticated caching; much more complex
  (AuthCache module)

• More core patches; http://
  tag1consulting.com/patches

• Denormalize your tables (Materialized View
  API)   if you’re on fire




                                        !"#$%&#'()
Now the real big thing


• The biggest bottleneck: the code
• Too many modules (feature creep)
• Poor code, slow queries
• “Bad” modules usually results from “bad” engineering




                                                         !"#$%&#'()
Find out the culprit


• Slow query logs (MySQL)
• Slow script logs (PHP-FPM)
• Code Profiling; XHProf, XDebug
• Testingthe good old “disable and load the page”




                                                    !"#$%&#'()
Dealing with the situation

• Buy some time:
 • Quick wins; Opcode, Memcache
 • Switch to NGINX+PHP-FPM
 • Cleanup your configuration
 • Cache anonymous traffic (Boost or
    Varnish)

• Clean up the mess
                                       !"#$%&#'()
Next step; front-end

• Complete separate topic;
 • CSS/JS aggregation,
 • parallelization & CDN,
 • Gzip compression,
 • sprites & image optimization...
• Code also matters here: optimize!
                                      !"#$%&#'()
Questions?
Go easy on me though, I’m sick today...




                                          !"#$%&#'()

Performance and scalability with drupal

  • 1.
    Whenever you’re ready... Performance & Scalability with Drupal !"#$%&#'()
  • 2.
    Who the hellis this guy? • I run Wiredcraft (http://wiredcraft.com) • We build (serious) Web and mobile solutions using Open Source technologies • We work with the United Nations, CNN, Nvidia... !"#$%&#'()
  • 3.
    What’s the deal? •Drupal is; • flexible & extensible • slow as hell • We want to; • deliver the content quickly to the user • optimize the use of backend resources !"#$%&#'()
  • 4.
    How do wedo that? • Analyze the bottleneck • Adapt the back-end and/or front-end • Test • Repeat !"#$%&#'()
  • 5.
    Now a fewadvices... • Add complexity incrementally • Scale vertically first • Focus on users not system administrators • Optimizing your code is a huge part of the equation !"#$%&#'()
  • 6.
    Analyze the bottleneck •Pimp up your shell skills • Problem: Network? Disk? CPU? Memory? • Source: Web server? App server? DB? • Caching is not magic; it adds complexity • For the long run, consider monitoring; Zabbix, Cacti, Nagios, Munin... !"#$%&#'()
  • 7.
    Web server • Cleanup your configuration (MPM, MaxClients, MaxRequestsPerChild, KeepAlive...) • Remove unnecessary modules • Consider switching to NGINX • Stress test (Apache Benchmark) • Scale horizontally; load balancer (HAproxy) !"#$%&#'()
  • 8.
    App server • Cleanup your configurationand add slow logs if possible • Remove unnecessary modules • Consider switching to CGI; PHP-FPM or FastCGI • Add an opcode; XCache, eAccelerator or APC !"#$%&#'()
  • 9.
    Database server • Cleanup your configuration and add slow logs • Add caching; Memcache • Switch from MyISAM to InnoDB • Scale horizontally; Master/Slave replication !"#$%&#'()
  • 10.
    What is Pressflow? •Patched version of Drupalfor performance purpose • Runs Drupal.org • Only works with PHP5 and MySQL • Supports M/S replication and reverse-proxy !"#$%&#'()
  • 11.
    Other optimizations... • Viewscaching • Block caching (Block Cache Alter module) • Reverse proxy (Varnish) or file caching (Boost) • Add a full text search engine; Solr, Sphinx, Elastic Search... Plenty of modules; Search API module, Searchlight... !"#$%&#'()
  • 12.
    And then somemore • Authenticated caching; much more complex (AuthCache module) • More core patches; http:// tag1consulting.com/patches • Denormalize your tables (Materialized View API) if you’re on fire !"#$%&#'()
  • 13.
    Now the realbig thing • The biggest bottleneck: the code • Too many modules (feature creep) • Poor code, slow queries • “Bad” modules usually results from “bad” engineering !"#$%&#'()
  • 14.
    Find out theculprit • Slow query logs (MySQL) • Slow script logs (PHP-FPM) • Code Profiling; XHProf, XDebug • Testingthe good old “disable and load the page” !"#$%&#'()
  • 15.
    Dealing with thesituation • Buy some time: • Quick wins; Opcode, Memcache • Switch to NGINX+PHP-FPM • Cleanup your configuration • Cache anonymous traffic (Boost or Varnish) • Clean up the mess !"#$%&#'()
  • 16.
    Next step; front-end •Complete separate topic; • CSS/JS aggregation, • parallelization & CDN, • Gzip compression, • sprites & image optimization... • Code also matters here: optimize! !"#$%&#'()
  • 17.
    Questions? Go easy onme though, I’m sick today... !"#$%&#'()