SlideShare a Scribd company logo
Drupal 超速指引
     How to Speed Up Drupal
                   2011 Drupalcamp Taipei
Jimmy Huang        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 如何檢測效能 ( 續 )
[DCTPE2011] 8) 多伺服器/高效能的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
實戰 – 記憶體快取
# ab -c 100 -t 30 http://netivism.com.tw/
          Document Path:           /
          Document Length:           33246 bytes
Before…
          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
# ab -c 100 -t 30 http://netivism.com.tw/
           Document Path:           /
           Document Length:           33246 bytes
After
          Concurrency Level:      100
Memcache:
          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
After
         Concurrency Level:      100
Boost:
         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
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/

More Related Content

PPT
Drupal performance (in DrupalCamp Taipei)
PPTX
Make your web faster
PPT
Using CDN to improve performance
PDF
一个 Mongodb command 的前世今生
PPT
Lamp优化实践
PDF
Mesos intro
PPTX
服务器端性能优化
PPTX
cdn的那些事儿
Drupal performance (in DrupalCamp Taipei)
Make your web faster
Using CDN to improve performance
一个 Mongodb command 的前世今生
Lamp优化实践
Mesos intro
服务器端性能优化
cdn的那些事儿

Viewers also liked (20)

PDF
[DCTPE2011] Drupal 6 的 CCK/Views運用--黎偉志
PPT
[DCTPE2010] 開場:Drupal與Drupal台灣
PDF
[DCTPE2011] 3) 主題演講:用Drupal 打造更美好的網際網路
PDF
[DCTPE2010] 如何開發 CCK 欄位模組
PPT
[DCTPE2010] Drupal 遇上行動網路服務
PDF
[DCTPE2010] Drupal 與網路的未來趨勢
PDF
[DCTPE2011] 11) Drupal 是好的生財工具嗎? 2. 中小型網站製作公司/工作室座談
PDF
[DCTPE2010] Drupal & (Open/Anti) Government
PDF
[DCTPE2011] 11) Drupal 是好的生財工具嗎? 1. 網站標案經驗分享 x 2
PPT
[DCTPE2010] 從企劃到開發維護的 Drupal 專案經驗
PPT
[DCTPE2011] Drupal 7 的Fields/Views 運用
PDF
[DCTPE2010] Open Hopen 政府網站的理想與現實
PDF
[DCTPE2010] Biodiversity & Drupal
PPTX
[DCTPE2010] Drupalcamp 商業案例:獎金獵人 share
PDF
[DCTPE2011] Drupal 6 的 CCK/Views運用--林振昇
PPT
[DCTPE2010] Drupal 學術應用-申請入學網路單一窗口
PDF
[DCTPE2011] 5) 用 Drupal 打造美好資訊架構(英/中雙語)
PDF
[DCTPE2011] 7) Mobile Drupal(英/中雙語)
PDF
[DCTPE2011] 8) 多伺服器/高效能的Drupal 主機解決方案--James Liu
PDF
[DCTPE2011] 10) Drupal與Facebook交朋友
[DCTPE2011] Drupal 6 的 CCK/Views運用--黎偉志
[DCTPE2010] 開場:Drupal與Drupal台灣
[DCTPE2011] 3) 主題演講:用Drupal 打造更美好的網際網路
[DCTPE2010] 如何開發 CCK 欄位模組
[DCTPE2010] Drupal 遇上行動網路服務
[DCTPE2010] Drupal 與網路的未來趨勢
[DCTPE2011] 11) Drupal 是好的生財工具嗎? 2. 中小型網站製作公司/工作室座談
[DCTPE2010] Drupal & (Open/Anti) Government
[DCTPE2011] 11) Drupal 是好的生財工具嗎? 1. 網站標案經驗分享 x 2
[DCTPE2010] 從企劃到開發維護的 Drupal 專案經驗
[DCTPE2011] Drupal 7 的Fields/Views 運用
[DCTPE2010] Open Hopen 政府網站的理想與現實
[DCTPE2010] Biodiversity & Drupal
[DCTPE2010] Drupalcamp 商業案例:獎金獵人 share
[DCTPE2011] Drupal 6 的 CCK/Views運用--林振昇
[DCTPE2010] Drupal 學術應用-申請入學網路單一窗口
[DCTPE2011] 5) 用 Drupal 打造美好資訊架構(英/中雙語)
[DCTPE2011] 7) Mobile Drupal(英/中雙語)
[DCTPE2011] 8) 多伺服器/高效能的Drupal 主機解決方案--James Liu
[DCTPE2011] 10) Drupal與Facebook交朋友
Ad

Similar to [DCTPE2011] 8) 多伺服器/高效能的Drupal 主機解決方案--黃雋 (12)

PPTX
如何利用 www.webpagetest.org 進行網頁效能分析與改進建議 (真實案例)
PDF
Performance 入門 - 前端工程開發實務訓練
PDF
twMVC#08 | 超。光速 網站最佳化實戰
PDF
超。光速 網站最佳化實戰 -twMVC#8
PDF
Modern php ch8 ch9 guide 導讀
PDF
A brief introduction to SPDY - 邁向 HTTP/2.0
PDF
前端性能优化和自动化
PDF
人多嘴雜乎?眾志成城乎?開放源碼軟體的使用體驗 by Bob Chao
PDF
COSCUP promoting in HP7
PDF
Lamp高性能设计
PPT
高性能Lamp程序设计 付超群
PDF
Php及drupal性能优化系列(二)
如何利用 www.webpagetest.org 進行網頁效能分析與改進建議 (真實案例)
Performance 入門 - 前端工程開發實務訓練
twMVC#08 | 超。光速 網站最佳化實戰
超。光速 網站最佳化實戰 -twMVC#8
Modern php ch8 ch9 guide 導讀
A brief introduction to SPDY - 邁向 HTTP/2.0
前端性能优化和自动化
人多嘴雜乎?眾志成城乎?開放源碼軟體的使用體驗 by Bob Chao
COSCUP promoting in HP7
Lamp高性能设计
高性能Lamp程序设计 付超群
Php及drupal性能优化系列(二)
Ad

More from Drupal Taiwan (7)

PDF
[DCTPE2011] 9) 案例分析 1. NNCF.org - Content, Commerce, CRM
PDF
[DCTPE2011]Drupalthon intro
PPT
[DCTPE2010] Drupal & 電子商務-Ubercart 實例介紹:線上書店
PPT
[DCTPE2010] 多站架設商業應用與實務-以本土癮科技為例
PPT
[DCTPE2010] 綠界科技-網路金流機制服務簡介
PDF
[DCTPE2010] Microsoft
PDF
[DCTPE2010] Drupal 模組開發入門
[DCTPE2011] 9) 案例分析 1. NNCF.org - Content, Commerce, CRM
[DCTPE2011]Drupalthon intro
[DCTPE2010] Drupal & 電子商務-Ubercart 實例介紹:線上書店
[DCTPE2010] 多站架設商業應用與實務-以本土癮科技為例
[DCTPE2010] 綠界科技-網路金流機制服務簡介
[DCTPE2010] Microsoft
[DCTPE2010] Drupal 模組開發入門

[DCTPE2011] 8) 多伺服器/高效能的Drupal 主機解決方案--黃雋