Drupal 超速指引 How to Speed Up Drupal Jimmy Huang 2011 Drupalcamp Taipei email: Jimmy at netivism.com.tw blog: jimmyhub.net
高效能 Drupal 策略 小比大好,少比多好,瘦比胖好 不該出現的不要出現 不需裝的不要裝 不需即時運算的就快取 記憶體比資料庫好 資料庫比檔案好
如何擬定效能改善方針 瓶頸在哪裡? 慢再哪裡? CPU /  記憶體  /  流量? 哪個頁面發生這個問題? 慢再何時? 檢測瓶頸 CPU :  確認是 Apache 還是 MySQL 記憶體  :  確認沒有用到 Swap 磁區 流量  :  確認連線場所網路順暢 頁面  :  確認某些頁面特別久
如何擬定效能改善方針  ( 續 ) 哪個網頁特別龜? 登入時瀏覽和登出時瀏覽的差異? 租用哪家 Server ?有權限做 Server 調整? 每日造訪頁數 ( awstats / google analytics ) ? 很多人看?還是很多爬蟲?
如何擬定效能改善方針  ( 續 ) 安裝模組 ex. memcache, boost, csstidy … 調整 Server ex. Apache MaxClients 數值 ex. Mod Deflate  調整  Drupal  設定 根據檢測出來的頁面,調整對應設定 調整程式碼 非不得已,自行開發模組,再調整程式碼
在  Drupal  如何檢測效能 Devel  觀察記憶體  /  頁面產生速度 Devel  蒐集 Database 使用的狀況 分析 Query 問題、來源 調整出問題之 Views / Panels /  程式碼
在  Drupal  如何檢測效能 ( 續 ) garland, system, block, dblog, filter, menu, node, taxonomy, user, content, date, date_api, date_repeat, date_timezone, number, optionwidgets, text, feeds, feeds_ui, feeds_xpathparser, ctools, job_scheduler, devel, views, views_ui
在  Drupal  如何檢測效能 ( 續 )
 
檢測效能 –  Apache / MySQL
檢測效能 – 流量問題
檢測效能 – 流量問題
實戰  - css / javascript aggregration Before…
實戰  - css / javascript aggregration After…
實戰  - html / css / javascript  壓縮 Before…
實戰  - html / css / javascript  壓縮 ( 續 ) After…
實戰  - html / css / javascript  壓縮 ( 續 ) use: http://www.seoconsultants.com/tools/compression
實戰  - html / css / javascript  壓縮 ( 續 ) Apache mod_deflate  開啟 Page Compression  開啟 第三方模組 Advanced CSS/JS Aggregation CSS Gzip CSSTidy
實戰 – 快取技術 Drupal 快取方式 Menu , Form, Page, Variables, Content, Language … 快取技術 Drupal 內建整頁  HTML 快取 Views / Panels  模組快取 Boost  模組
Drupal 頁面快取
Views 快取
Panel 快取
Boost 快取
實戰 – 記憶體快取 為何把快取放進記憶體? 建立 Database 連線緩慢 MySQL 的效能不足 Database 新增、刪除的動作比記憶體慢 如何做? 安裝 memcached 安裝 php-memcache 安裝 drupal memcache
實戰 – 記憶體快取
Before… # ab -c 100 -t 30 http://netivism.com.tw/ Document Path:  / Document Length:  33246 bytes Concurrency Level:  100 Time taken for tests:  30.085 seconds Complete requests:  130 Failed requests:  0 Write errors:  0 Total transferred:  4992040 bytes HTML transferred:  4920408 bytes Requests per second:  4.32 [#/sec] (mean) Time per request:  23142.220 [ms] (mean) Time per request:  231.422 [ms] (mean, across all concurrent requests) Transfer rate:  162.04 [Kbytes/sec] received
After Memcache: # ab -c 100 -t 30 http://netivism.com.tw/ Document Path:  / Document Length:  33246 bytes Concurrency Level:  100 Time taken for tests:  30.021 seconds Complete requests:  432 Failed requests:  0 Write errors:  0 Total transferred:  14976120 bytes HTML transferred:  14761224 bytes Requests per second:  14.39 [#/sec] (mean) Time per request:  6949.333 [ms] (mean) Time per request:  69.493 [ms] (mean, across all concurrent requests) Transfer rate:  487.16 [Kbytes/sec] received
# ab -c 100 -t 30 http://netivism.com.tw/ Document Path:  / Document Length:  33329 bytes Concurrency Level:  100 Time taken for tests:  30.009 seconds Complete requests:  5113 Failed requests:  0 Write errors:  0 Total transferred:  172425088 bytes HTML transferred:  170310941 bytes Requests per second:  170.38 [#/sec] (mean) Time per request:  586.922 [ms] (mean) Time per request:  5.869 [ms] (mean, across all concurrent requests) Transfer rate:  5611.05 [Kbytes/sec] received After Boost:
Before After
參考資源 Web resource Drupal效能相關模組   (drupal.org) Drupal效能群組   (group.drupal.org) Drupal Performance Handbook  (drupal.org) Drupal Performance Tuning  (2bits) Book Drupal 6 Performance Tips  (PACKT) Drupal Performance and Scalability  (Lullabot)
photo list http://www.flickr.com/photos/17612257@N00/4639794109/ http://gala4th.blogspot.com/2009_09_01_archive.html   http://www.flickr.com/photos/runforcover/3791930953/   http://www.flickr.com/photos/cyberslayer/5874026128/   http://www.flickr.com/photos/marcovdz/4520986339/   http://www.flickr.com/photos/bwjones/4227870410/   http://www.flickr.com/photos/adcuz/3104028585/   http://www.flickr.com/photos/antphotos/3469245178/   http://www.flickr.com/photos/kino/487539637/in/photostream/   http://www.flickr.com/photos/nathey4/5713434731/ http://bumpshack.com/2010/08/06/sara-rue-incredible-weight-loss-before-after-photos/

Drupal performance (in DrupalCamp Taipei)

  • 1.
    Drupal 超速指引 Howto Speed Up Drupal Jimmy Huang 2011 Drupalcamp Taipei email: Jimmy at netivism.com.tw blog: jimmyhub.net
  • 2.
    高效能 Drupal 策略小比大好,少比多好,瘦比胖好 不該出現的不要出現 不需裝的不要裝 不需即時運算的就快取 記憶體比資料庫好 資料庫比檔案好
  • 3.
    如何擬定效能改善方針 瓶頸在哪裡? 慢再哪裡?CPU / 記憶體 / 流量? 哪個頁面發生這個問題? 慢再何時? 檢測瓶頸 CPU : 確認是 Apache 還是 MySQL 記憶體 : 確認沒有用到 Swap 磁區 流量 : 確認連線場所網路順暢 頁面 : 確認某些頁面特別久
  • 4.
    如何擬定效能改善方針 (續 ) 哪個網頁特別龜? 登入時瀏覽和登出時瀏覽的差異? 租用哪家 Server ?有權限做 Server 調整? 每日造訪頁數 ( awstats / google analytics ) ? 很多人看?還是很多爬蟲?
  • 5.
    如何擬定效能改善方針 (續 ) 安裝模組 ex. memcache, boost, csstidy … 調整 Server ex. Apache MaxClients 數值 ex. Mod Deflate 調整 Drupal 設定 根據檢測出來的頁面,調整對應設定 調整程式碼 非不得已,自行開發模組,再調整程式碼
  • 6.
    在 Drupal 如何檢測效能 Devel 觀察記憶體 / 頁面產生速度 Devel 蒐集 Database 使用的狀況 分析 Query 問題、來源 調整出問題之 Views / Panels / 程式碼
  • 7.
    在 Drupal 如何檢測效能 ( 續 ) garland, system, block, dblog, filter, menu, node, taxonomy, user, content, date, date_api, date_repeat, date_timezone, number, optionwidgets, text, feeds, feeds_ui, feeds_xpathparser, ctools, job_scheduler, devel, views, views_ui
  • 8.
    在 Drupal 如何檢測效能 ( 續 )
  • 9.
  • 10.
    檢測效能 – Apache / MySQL
  • 11.
  • 12.
  • 13.
    實戰 -css / javascript aggregration Before…
  • 14.
    實戰 -css / javascript aggregration After…
  • 15.
    實戰 -html / css / javascript 壓縮 Before…
  • 16.
    實戰 -html / css / javascript 壓縮 ( 續 ) After…
  • 17.
    實戰 -html / css / javascript 壓縮 ( 續 ) use: http://www.seoconsultants.com/tools/compression
  • 18.
    實戰 -html / css / javascript 壓縮 ( 續 ) Apache mod_deflate 開啟 Page Compression 開啟 第三方模組 Advanced CSS/JS Aggregation CSS Gzip CSSTidy
  • 19.
    實戰 – 快取技術Drupal 快取方式 Menu , Form, Page, Variables, Content, Language … 快取技術 Drupal 內建整頁 HTML 快取 Views / Panels 模組快取 Boost 模組
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
    實戰 – 記憶體快取為何把快取放進記憶體? 建立 Database 連線緩慢 MySQL 的效能不足 Database 新增、刪除的動作比記憶體慢 如何做? 安裝 memcached 安裝 php-memcache 安裝 drupal memcache
  • 25.
  • 26.
    Before… # ab-c 100 -t 30 http://netivism.com.tw/ Document Path: / Document Length: 33246 bytes Concurrency Level: 100 Time taken for tests: 30.085 seconds Complete requests: 130 Failed requests: 0 Write errors: 0 Total transferred: 4992040 bytes HTML transferred: 4920408 bytes Requests per second: 4.32 [#/sec] (mean) Time per request: 23142.220 [ms] (mean) Time per request: 231.422 [ms] (mean, across all concurrent requests) Transfer rate: 162.04 [Kbytes/sec] received
  • 27.
    After Memcache: #ab -c 100 -t 30 http://netivism.com.tw/ Document Path: / Document Length: 33246 bytes Concurrency Level: 100 Time taken for tests: 30.021 seconds Complete requests: 432 Failed requests: 0 Write errors: 0 Total transferred: 14976120 bytes HTML transferred: 14761224 bytes Requests per second: 14.39 [#/sec] (mean) Time per request: 6949.333 [ms] (mean) Time per request: 69.493 [ms] (mean, across all concurrent requests) Transfer rate: 487.16 [Kbytes/sec] received
  • 28.
    # ab -c100 -t 30 http://netivism.com.tw/ Document Path: / Document Length: 33329 bytes Concurrency Level: 100 Time taken for tests: 30.009 seconds Complete requests: 5113 Failed requests: 0 Write errors: 0 Total transferred: 172425088 bytes HTML transferred: 170310941 bytes Requests per second: 170.38 [#/sec] (mean) Time per request: 586.922 [ms] (mean) Time per request: 5.869 [ms] (mean, across all concurrent requests) Transfer rate: 5611.05 [Kbytes/sec] received After Boost:
  • 29.
  • 30.
    參考資源 Web resourceDrupal效能相關模組 (drupal.org) Drupal效能群組 (group.drupal.org) Drupal Performance Handbook (drupal.org) Drupal Performance Tuning (2bits) Book Drupal 6 Performance Tips (PACKT) Drupal Performance and Scalability (Lullabot)
  • 31.
    photo list http://www.flickr.com/photos/17612257@N00/4639794109/http://gala4th.blogspot.com/2009_09_01_archive.html http://www.flickr.com/photos/runforcover/3791930953/ http://www.flickr.com/photos/cyberslayer/5874026128/ http://www.flickr.com/photos/marcovdz/4520986339/ http://www.flickr.com/photos/bwjones/4227870410/ http://www.flickr.com/photos/adcuz/3104028585/ http://www.flickr.com/photos/antphotos/3469245178/ http://www.flickr.com/photos/kino/487539637/in/photostream/ http://www.flickr.com/photos/nathey4/5713434731/ http://bumpshack.com/2010/08/06/sara-rue-incredible-weight-loss-before-after-photos/