Slide 1

Slide 1 text

Optimize Drupal Make your Drupal site faster Thursday, July 18, 13

Slide 2

Slide 2 text

Lê Thanh Sang • http://drupal.org/user/204321 • Skype: mr.lamphong • 5 years with Drupal • Captain of Sang.IO • Senior Drupal Developer at GO1 Thursday, July 18, 13

Slide 3

Slide 3 text

Agenda • Hardware • WebServer • Drupal • FrontEnd • Monitor Thursday, July 18, 13

Slide 4

Slide 4 text

Hardware • Many CPU as possible • Faster disk IO as possible (Sata < SAS < SSD < PCI Flash) Thursday, July 18, 13

Slide 5

Slide 5 text

Web Server • Reverse Proxy • Nginx for static file • Percona Database server • PHP-FPM + Opcode (APC, Xcache, eAccelerator) • Redis or Memcache Thursday, July 18, 13

Slide 6

Slide 6 text

Web Server - Reverse Proxy • Use nginx or varnish • Cache content on RAM (Create a mount point using tmpfs) • Allow flush cache on Internal IP. Use purge module on Drupal. Thursday, July 18, 13

Slide 7

Slide 7 text

Web Server • Using nginx if you can. Apache is fine, use Reverse Proxy for faster. • Using mod_pagespeed (http:// code.google.com/p/modpagespeed/) • For nginx: https://github.com/pagespeed/ ngx_pagespeed Thursday, July 18, 13

Slide 8

Slide 8 text

Database Server • PerconaDB or MariaDB • Don’t use same server with Drupal if you can. • Use master for write • Slave replication for read Thursday, July 18, 13

Slide 9

Slide 9 text

PHP-FPM • Running via socket (faster than TCP/IP) • Only install extension we need • Set max_request • Turn off log for production Thursday, July 18, 13

Slide 10

Slide 10 text

Drupal • Use Pressflow (Require PHP 5) • Block cache • Redis cache • Authenticated cache • Remove slow module (Statistics, admin_menu, tagadelic, nice menus) • Using xdebug or xhprof for profiling Thursday, July 18, 13

Slide 11

Slide 11 text

Drupal theme • Never use a function in the tpl file, always on the preprocess function • In tpl only print variables • Only use hook_theme (theme, process, preprocess) Thursday, July 18, 13

Slide 12

Slide 12 text

Drupal search • Don’t use default DB search • Use search_api • Solr or Elastic Search Thursday, July 18, 13

Slide 13

Slide 13 text

FrontEnd • Browser can send 4~6 request per domain (2 for IE). • CSS/JS aggregation • CDN, Gzip compression, sprites, image optimization (Done if using mog_pagespeed) Thursday, July 18, 13

Slide 14

Slide 14 text

Summary Upgrade your hardware is alway a best solution Thursday, July 18, 13

Slide 15

Slide 15 text

Monitor munin monit vnstat htop Thursday, July 18, 13

Slide 16

Slide 16 text

Question? Lê Thanh Sang le@thanhsang.me Thursday, July 18, 13