Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide


  1. 1. Speed up Drupal Alex Scutaru Technical Leader,
  2. 2. Content: 1. Introduction 2. Basic actions 3. Performance problems. Bottlenecks 4. Goals 5. Drupal performance settings 6. Drupal settings, modules 7. Optcode caching. APC 8. Compression. Logging 9. Varnish 10. Memcache 11. Caching
  3. 3. Introduction: • Why we need scaling and performance tunning? • Users are not happy with 5 seconds loading time • Site traffic grow and your server is not more capable to fulfill all
  4. 4. Basic actions: • Scale Up - add more memory - upgrade CPU - switch to SSD • Scale Out - move the database server to a different physical machine - pay attention to network latency - use Apache Solr as a search backend - add more web servers, use a load balancer (hardware and/or Varnish) • Update PHP to the latest version compatible with your Drupal version • Update Drupal core and contrib
  5. 5. Performance problems. Bottlenecks: • Apache - each process/request use a lot of memory - number of concurrent requests is limited to server memory • Database - Drupal execute hundreds of queries for each page - table locks and not optimized queries increase page execution time - network latency if database is on different physical machine • Filesystem - a lot of php files to load for each request - php/apache logs - static files
  6. 6. Goals: • Decrease number of http requests to Apache • Decrease filesystem usage • Less database
  7. 7. Drupal performance settings: • Turn on CSS and JS aggregation - less http requests, less apache child process running on server. • Cache pages for anonymous users - save generated pages in Drupal cache - save a lot of database and php resources - also improve authenticated users experience indirectly • Cache blocks - works also for authenticated users • Adjust cache lifetime • Adjust expiration of cached pages. It is basically the browser cache. • Use CSS sprites to decrease http requests • Optimize images for web. Pay attention to png (
  8. 8. Drupal settings, Modules: • Minimize the number of modules you use, review each installed module to find out if you really need it. • Minimize the number of custom modules, group the code in one or couple of modules. • Less modules you load, less memory is used • Disable Database Logging module. Use Syslog module. • Disable Cron. Use crontab to run cron. • Use drush cron instead of wget (drush will run as a cli php script avoiding overhead from apache) • Send emails from cron • Avoid using external http calls during regular page execution. Move it to cron and aggregate
  9. 9. Optcode caching. APC: • Avoid the overhead of parsing and compiling source code on each request • Decrease CPU and memory usage • Minimize filesystem usage by configuring APC with apc.stat="1" to skip file check. Require an apache restart after deploying code
  10. 10. Compression. Logging: • Enable file compression by MIME type with mod_deflate AddOutputFilterByType DEFLATE text/* application/javascript  application/x­javascript application/rss+xml application/xml • Fix all code errors/warnings to write less logs • Configure php to ignore notice messages • Minimize the apache access log by ignoring requests to static content setenvIf Request_URI ".(jpg|jpeg|png|css|gif|ico|js)$" dontlog CustomLog /var/log/httpd­access.log combined env=!
  11. 11. Varnish: • Use Varnish to cache pages and static content for anonymous users • Configure Apache to listen to port 8080 and Varnish on 80 • Varnish will store generated pages in memory • Use devnull module to avoid double caching for cache_page • Considerably decrease the number of apache processes. Saving CPU and memory • Cache static content for authenticated users if (req.url ~ ".(png|gif|jpeg|jpg|ico|swf|css|js|html|htm)(?[a­ z0­9]+)?$") {   unset req.http.Cookie; } • If you have same content to display for some pages for authenticated users you can configure Varnish and Drupal to cache these
  12. 12. Memcache: • Use Memcache as a default caching engine for Drupal - get rid of database writes/reads to _cache tables - much faster than database • Use for session handling • Use for Locking (expensive write queries) • Separate memcache daemon for sessions • Set Locking to use the same daemon as
  13. 13. Caching strategy: • Cache as much elements as possible • Analyze each panel, minipanel, view to find out if you can cache them • Using content access restriction modules like OG will disable block caching. Put the content in minipanels, cache it and display as a block • Cache menus using the same rule if you have menu access restrictions. They use a lot of database queries to check
  14. 14. Thanks! Questions?
  15. 15. Strategy, Design & Technology to create value and reach your goals.