2. 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...
!"#$%&#'()
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 we do that?
• Analyze the bottleneck
• Adapt the back-end and/or front-end
• Test
• Repeat
!"#$%&#'()
5. 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
!"#$%&#'()
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
• Clean up 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
• 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
!"#$%&#'()
9. Database server
• Clean up 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...
• 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...
!"#$%&#'()
12. 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
!"#$%&#'()
13. 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
!"#$%&#'()
14. 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”
!"#$%&#'()
15. 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
!"#$%&#'()
16. Next step; front-end
• Complete separate topic;
• CSS/JS aggregation,
• parallelization & CDN,
• Gzip compression,
• sprites & image optimization...
• Code also matters here: optimize!
!"#$%&#'()