動態網頁快取系統之設計與實作 design and implementation of caching dynamic web pages...
Post on 21-Dec-2015
287 views
TRANSCRIPT
動態網頁快取系統之設計與實作動態網頁快取系統之設計與實作Design and Implementation Design and Implementation
of Caching Dynamic Web of Caching Dynamic Web PagesPages
張 燕 張 燕 光光
2
大綱大綱► 研究動機與目的 研究動機與目的 ► 文獻探討 文獻探討 ► 系統設計與實作 系統設計與實作 ► 系統效能評估 系統效能評估 ► 結論與未來展望 結論與未來展望
3
研究動機與目的研究動機與目的►研究動機研究動機
網頁快取向來是解決因 網頁快取向來是解決因 WWW WWW 快速成長而造成網路壅快速成長而造成網路壅塞、回應遲緩等問題的最佳方案塞、回應遲緩等問題的最佳方案
動態網頁已成今日網路服務之主流方式,但現今之網頁動態網頁已成今日網路服務之主流方式,但現今之網頁快取系統仍無法快取動態網頁快取系統仍無法快取動態網頁
►研究目的研究目的 快取動態網頁快取動態網頁,,以能增進網路服務品質以能增進網路服務品質
►縮短客戶端之等待時間縮短客戶端之等待時間►提升伺服器之處理能力提升伺服器之處理能力►減輕網路之壅塞情況減輕網路之壅塞情況
4
文獻探討文獻探討►現行網頁快取系統之分類現行網頁快取系統之分類►動態網頁快取機制之研究動態網頁快取機制之研究►動態網頁於快取上之問題定義動態網頁於快取上之問題定義
5
現行網頁快取系統之分類現行網頁快取系統之分類►Browser CacheBrowser Cache►Proxy CacheProxy Cache
Forward ProxyForward Proxy Transparent ProxyTransparent Proxy Reverse ProxyReverse Proxy
►Server-Side CacheServer-Side Cache
ClientClientClientClient
ServerServerServerServer
Browser CacheBrowser CacheBrowser CacheBrowser Cache
Server-Side Server-Side CacheCache
Server-Side Server-Side CacheCache
Forward ProxyForward ProxyForward ProxyForward Proxy Transparent Transparent ProxyProxy
Transparent Transparent ProxyProxy
Reverse ProxyReverse ProxyReverse ProxyReverse Proxy
6
Reverse ProxyReverse Proxy
►Also called Also called Proxy AcceleratorProxy Accelerator►Server FarmServer Farm (伺服器叢集)之前端 (伺服器叢集)之前端 ►重導重導 (redirect)(redirect) 客戶端之請求至適當的伺服客戶端之請求至適當的伺服
器來處理,而由於器來處理,而由於 Reverse ProxyReverse Proxy 具有此種具有此種分配客戶端請求之能力,故也可作為分配客戶端請求之能力,故也可作為 Server Server FarmFarm 之之 Load BalancerLoad Balancer (負載平衡器),(負載平衡器),平均分攤各個伺服器的工作量平均分攤各個伺服器的工作量
►Web SwitchWeb Switch
7
Server-basedServer-based
►做法做法::儲存動態網頁成靜態網頁,並放置於網儲存動態網頁成靜態網頁,並放置於網頁伺服器後端的快取系統中頁伺服器後端的快取系統中 優點優點::避免伺服器端計算資源的重複性浪費,藉以避免伺服器端計算資源的重複性浪費,藉以減少客戶端等待伺服器端計算之時間花費減少客戶端等待伺服器端計算之時間花費
Dynamic Web Data Caching (A. Iyengar, Dynamic Web Data Caching (A. Iyengar, INFOCOM'99)INFOCOM'99)►ODGODG (( Object Dependence GraphObject Dependence Graph )來輔助快取文件間彼此)來輔助快取文件間彼此
資料內容之相依性的管理 資料內容之相依性的管理 CachumaCachuma ( ( Huican Zhu & Tao YangHuican Zhu & Tao Yang, , IINFOCOM‘01NFOCOM‘01
))►可對快取文件作可對快取文件作 InvalidationInvalidation 與與 PrecomputingPrecomputing 等一系列管理機等一系列管理機
制。 制。
8
Server-basedServer-based
►Server-basedServer-based CachumaCachuma
9
Server-basedServer-based :References :References
1.1. Arun Iyengar, Jim Challenger, "Arun Iyengar, Jim Challenger, "Improving Improving Web Server Performance by Caching Web Server Performance by Caching Dynamic DataDynamic Data", ", In Proc. of the USENIX In Proc. of the USENIX Symposium on Internet Technologies and Symposium on Internet Technologies and Systems Monterey, CaliforniaSystems Monterey, California, Dec 1997., Dec 1997.
2.2. Huican Zhu, Tao Yang, "Huican Zhu, Tao Yang, "Class-based Cache Class-based Cache Management for Dynamic Web ContentManagement for Dynamic Web Content", ", IEEE InfocomIEEE Infocom, 2001., 2001.
3.3. Jim Challenger, Arun Iyengar, Paul Dantzig, Jim Challenger, Arun Iyengar, Paul Dantzig, ""A Scalable System for Consistently A Scalable System for Consistently Caching Dynamic Web DataCaching Dynamic Web Data",", In Proc of In Proc of IEEE INFOCOM'99, New YorkIEEE INFOCOM'99, New York, Mar 1999., Mar 1999.
10
Proxy-basedProxy-based
► Proxy-basedProxy-based 做法做法::使用使用 Proxy CacheProxy Cache 內已有之快取文件內已有之快取文件 segmentssegments ,,並在並在 ProxyProxy 內直接組合而成一完整網頁供用戶端使用內直接組合而成一完整網頁供用戶端使用
優點優點::較較 Server-basedServer-based 多了一項預期效益 多了一項預期效益 — — 減少整體減少整體網網 路使用量 路使用量
範例範例:: Active CacheActive Cache ( ( Pei Cao, et al., 1998Pei Cao, et al., 1998 ))
Proxy CacheProxy Cache
Cache AppletCache Applet Cache ObjectsCache ObjectsClientClientClientClient Web ServerWeb ServerWeb ServerWeb Server
11
Language-basedLanguage-based► Language-basedLanguage-based
做法:使用自定之快取語言或標籤,可達成動態網頁中做法:使用自定之快取語言或標籤,可達成動態網頁中 之動、靜態內容分離,或是直接 之動、靜態內容分離,或是直接
使用動態網頁語 使用動態網頁語 言研發動態網頁快取系統 言研發動態網頁快取系統 優點:可增進客戶端與伺服器端二者間之動態網頁處理優點:可增進客戶端與伺服器端二者間之動態網頁處理
與遞送之效能 與遞送之效能 範例:範例: HPP (Hypertext Pre-Processing) and BigwigHPP (Hypertext Pre-Processing) and Bigwig
12
Language-based:Language-based: ReferencesReferences
► Claus Brabrand, Anders Møller, Steffan Olesen, Claus Brabrand, Anders Møller, Steffan Olesen, Michael I. Schwartzbach, "Language-Based Michael I. Schwartzbach, "Language-Based Caching of Dynamically Generated HTML", Caching of Dynamically Generated HTML", World Wide Web Journal, Vol. 5, No. 4: 305-World Wide Web Journal, Vol. 5, No. 4: 305-323, Kluwer Academic Publishers, 2002.323, Kluwer Academic Publishers, 2002.
► Fred Douglis, Michael Rabinovich, Antonio Fred Douglis, Michael Rabinovich, Antonio Haro, "HPP: HTML Macro-Preprocessing to Haro, "HPP: HTML Macro-Preprocessing to Support Dynamic Document Caching", In Proc. Support Dynamic Document Caching", In Proc. of the USENIX Symposium on Internet of the USENIX Symposium on Internet Technologies and Systems Monterey, Technologies and Systems Monterey, California, Dec 1997.California, Dec 1997.
13
Application-basedApplication-based► Application-basedApplication-based
做法做法:直接使用動態網頁程式語言來設計動態網頁快取:直接使用動態網頁程式語言來設計動態網頁快取系統,其做法主要是由負責產生動態網頁之動態網頁應系統,其做法主要是由負責產生動態網頁之動態網頁應用程式,在產生動態網頁之同時,也順道快取本身所產用程式,在產生動態網頁之同時,也順道快取本身所產生的動態網頁成靜態快取文件,待下次客戶端再有相同生的動態網頁成靜態快取文件,待下次客戶端再有相同請求時,請求時,
優點優點:動態網頁應用程式即可直接取用先前所快取之靜:動態網頁應用程式即可直接取用先前所快取之靜態快取文件,故其可省去再次執行完整動態網頁應用程態快取文件,故其可省去再次執行完整動態網頁應用程式所須耗費之伺服器運算資源與時間式所須耗費之伺服器運算資源與時間
範例:範例: phpCachephpCache ( ( http://0x00.org/php/phpCache/ http://0x00.org/php/phpCache/ ))
Web ServerWeb ServerWeb ServerWeb Server phpCachephpCachephpCachephpCache PHPPHPWeb AppsWeb Apps
PHPPHPWeb AppsWeb Apps
14
動態網頁之產生過程動態網頁之產生過程
Web ServerWeb ServerWeb ServerWeb Server
Web AppWeb App
if ( Key ==...) if ( Key ==...) {………..}{………..}else if ( … ) else if ( … ) {…..}{…..}
Web AppWeb App
if ( Key ==...) if ( Key ==...) {………..}{………..}else if ( … ) else if ( … ) {…..}{…..}
HTML PageHTML Page
<HTML><HTML>………………....………………....</HTML></HTML>
HTML PageHTML Page
<HTML><HTML>………………....………………....</HTML></HTML>
RequestRequest ResponseResponse
http://site/webapp?Key=xxxhttp://site/webapp?Key=xxx
OutputOutput
ClientClientClientClient
15
Q1Q1 :客戶端傳遞參數值之方式:客戶端傳遞參數值之方式 http://host/abs_path/webapphttp://host/abs_path/webapp??
k1=v1&k2=v2 k1=v1&k2=v2 Squid-Cache Server Squid-Cache Server 之預設設定之預設設定
S1S1 :修改現有傳遞參數值方式:修改現有傳遞參數值方式 替換替換” ” ? “? “ 字元字元
動態網頁於快取上之問題定義動態網頁於快取上之問題定義(1/5)(1/5)
# TAG: no_cache# TAG: no_cache# We recommend you to use the following two lines.# We recommend you to use the following two lines.acl QUERY urlpath_regex acl QUERY urlpath_regex cgi-bincgi-bin \?\?no_cache deny QUERYno_cache deny QUERY
16
動態網頁於快取上之問題定義動態網頁於快取上之問題定義(2/5)(2/5)
Q2Q2 :動態網頁應用程式之執行延遲 :動態網頁應用程式之執行延遲 動態網頁應用程式如同一般的程式,執行時皆須動態網頁應用程式如同一般的程式,執行時皆須佔用伺服器之處理資源,而越多程式同時執行,佔用伺服器之處理資源,而越多程式同時執行,各個程式處理完成所需時間將越加延長各個程式處理完成所需時間將越加延長
S2S2 :保存程式之處理結果:保存程式之處理結果 只要確定參數值相同,即可重複使用只要確定參數值相同,即可重複使用
17
動態網頁於快取上之問題定義動態網頁於快取上之問題定義(3/5)(3/5)
Q3Q3 :動態網頁欠缺 :動態網頁欠缺 HTTP Cache-HTTP Cache-Control Control HeaderHeader 缺少 缺少 Cache-ControlCache-Control 、、 ExpiresExpires 、、
Last-ModifiedLast-Modified 、、 Content-LengthContent-Length
S3S3 :添加 :添加 HTTP Cache-Control Header HTTP Cache-Control Header 於動 於動 態網頁之前態網頁之前
18
動態網頁於快取上之問題定義動態網頁於快取上之問題定義(4/5)(4/5)
ClientClient ServerServer
Request Headers :Request Headers :GET /index.php HTTP/1.1GET /index.php HTTP/1.1Host: clotho.mi.chu.edu.twHost: clotho.mi.chu.edu.twAccept: */*Accept: */*Accept-Language: enAccept-Language: enUser-Agent: Lynx/2.8.5dev.7User-Agent: Lynx/2.8.5dev.7Connection: closeConnection: close
Response Headers :Response Headers :HTTP/1.1 200 OKHTTP/1.1 200 OKDate: Mon, 02 Jun 2003 07:16:22 GMTDate: Mon, 02 Jun 2003 07:16:22 GMTServer: Apache/2.0.45 (Unix) mod_perl/1.99_09 PHP/4.3.1Server: Apache/2.0.45 (Unix) mod_perl/1.99_09 PHP/4.3.1Accept-Ranges: bytesAccept-Ranges: bytesX-Powered-By: PHP/4.3.1X-Powered-By: PHP/4.3.1Connection: closeConnection: closeContent-Type: text/html; charset=ISO-8859-1Content-Type: text/html; charset=ISO-8859-1
19
動態網頁於快取上之問題定義動態網頁於快取上之問題定義(5/5)(5/5)
Q4Q4 :動態網頁之網路傳輸重複浪費:動態網頁之網路傳輸重複浪費 多數客戶端僅使用多數客戶端僅使用 Browser CacheBrowser Cache 動態網頁中之不變部分重複傳輸動態網頁中之不變部分重複傳輸
S4S4 :重複使用網頁中之不變部分:重複使用網頁中之不變部分 分離、組合動態網頁中之動、靜態內容分離、組合動態網頁中之動、靜態內容
20
系統設計與實作系統設計與實作►系統設計概念系統設計概念►Application-Level Application-Level 動態網頁快取系統動態網頁快取系統
系統整體架構與運作流程系統整體架構與運作流程 系統元件設計系統元件設計 系統實作系統實作
►Server-Level Server-Level 動態網頁快取系統動態網頁快取系統 系統整體架構與運作流程系統整體架構與運作流程 系統元件設計系統元件設計
21
系統設計概念系統設計概念
Web ServerWeb ServerWeb ServerWeb Server
If have cached If have cached dynamic web dynamic web
pagepage
If have cached If have cached dynamic web dynamic web
pagepageWeb AppWeb AppWeb AppWeb App
Cache DirectoryCache DirectoryCache DirectoryCache Directory HTML PageHTML PageHTML PageHTML Page
RequestRequestRequestRequest
ResponseResponseResponseResponse
NoNo
YesYes OutputOutput
SaveSave
With HTTP Cache-Control HeaderWith HTTP Cache-Control HeaderWith HTTP Cache-Control HeaderWith HTTP Cache-Control Header
22
Application-Level Application-Level 動態網頁快取動態網頁快取系統系統
StaticStatic
Web ServerWeb ServerWeb ServerWeb Server
Cache DirectoryCache DirectoryCache DirectoryCache Directory
Web AppsWeb Apps(( WADCWADC ))
Web AppsWeb Apps(( WADCWADC ))
Web SwitchWeb SwitchWeb SwitchWeb Switch
DynamicDynamic
ClientClientClientClient
SaveSave
Type BType B
Cache ManagerCache ManagerCache ManagerCache Manager
Type AType A
Save as .cmr Save as .cmr filefile
CompareCompare Update Update NotifyNotify
ResponseResponseResponseResponse
23
ALAL 系統元件設計系統元件設計– – Type B URL Type B URL (1/2)(1/2)
http://host/abs_path/page?k1=v1&k2=v2 http://host/abs_path/page?k1=v1&k2=v2 ( Type A URL )( Type A URL )
http://host/abs_path,page!k1=v1&k2=v2.html http://host/abs_path,page!k1=v1&k2=v2.html ( Type B ( Type B
URL )URL )
Apache Rewrite moduleApache Rewrite moduleRewriteMap urlparse prg: /urlparse.plRewriteCond %{REQUEST_FILENAME} !-sRewriteRule ^/(.+)/(.*)\.html$ $1${urlparse2:$2} [L]
24
ALAL 系統元件設計系統元件設計– – Type B URL Type B URL (2/2)(2/2)
<Script Language=JavaScript><Script Language=JavaScript>function Location() {function Location() {
var UrlStr;var UrlStr;UrlStr = "http://host/abs_path,page! k1=" + document.LocationBody.k1.value +UrlStr = "http://host/abs_path,page! k1=" + document.LocationBody.k1.value + "&k2=" + document.LocationBody.k2.value + ".html";"&k2=" + document.LocationBody.k2.value + ".html";window.location.href = UrlStr; }window.location.href = UrlStr; }
</Script></Script><Form Name=LocationBody><Form Name=LocationBody>Key 1: <Input Type=Text Name=k1><BR>Key 1: <Input Type=Text Name=k1><BR>Key 2: <Input Type=Text Name=k2><BR>Key 2: <Input Type=Text Name=k2><BR><Input Type=Button Value=Submit onClick="Location();"><Input Type=Button Value=Submit onClick="Location();"></Form></Form>
ClientClient
Web ServerWeb ServerWeb ServerWeb Serverhttp://host/abs_path,page!k1=v1&k2=v2.htmlhttp://host/abs_path,page!k1=v1&k2=v2.html
25
ALAL 系統元件設計系統元件設計– – Web SwitchWeb Switch
### AddType allows you to add to or override the MIME configuration# AddType allows you to add to or override the MIME configuration# file mime.types for specific file types.# file mime.types for specific file types.##AddType application/x-httpd-phpAddType application/x-httpd-php .php.php
RequestRequestRequestRequest
If the request is for If the request is for dynamic pagedynamic page
If the request is for If the request is for dynamic pagedynamic page
If the If the requested requested page existpage exist
If the If the requested requested page existpage exist
If URL is If URL is Type BType B
If URL is If URL is Type BType B
Executing the normal Executing the normal process for dynamic process for dynamic
pagepage
Executing the normal Executing the normal process for dynamic process for dynamic
pagepage
Executing the normal Executing the normal process for static pageprocess for static pageExecuting the normal Executing the normal process for static pageprocess for static page
Convert Type B Convert Type B URL into Type AURL into Type AConvert Type B Convert Type B
URL into Type AURL into Type A
NoNo
NoNo
YesYes
YesYes
URL Pre-processingURL Pre-processing
Web SwitchWeb Switch
NoNoYesYes
26
ALAL 系統元件設計系統元件設計– – WADCWADC
► Web Application Web Application Designed for Designed for Caching Caching (( WADWADCC )) 產生適當之產生適當之 HTTP HTTP
Cache-Control Cache-Control HeaderHeader
儲存動態網頁之內容而儲存動態網頁之內容而成快取文件成快取文件
知會知會 Cache ManagerCache Manager
Generating the Generating the dynamic contentdynamic contentGenerating the Generating the
dynamic contentdynamic content
Response the dynamic Response the dynamic content with HTTP content with HTTP
Cache-Control HeaderCache-Control Header
Response the dynamic Response the dynamic content with HTTP content with HTTP
Cache-Control HeaderCache-Control Header
Already Already Cached ?Cached ?Already Already Cached ?Cached ?
Save the dynamic Save the dynamic content as .cmr filecontent as .cmr fileSave the dynamic Save the dynamic
content as .cmr filecontent as .cmr file
Notify the Cache Notify the Cache ManagerManager
Notify the Cache Notify the Cache ManagerManager
Save the dynamic Save the dynamic content as cache content as cache
objectobject
Save the dynamic Save the dynamic content as cache content as cache
objectobject
YesYes NoNo
27
ALAL 系統元件設計系統元件設計– – Cache Manager Cache Manager (1/5)(1/5)
►快取文件屬性值之取得與存放快取文件屬性值之取得與存放 IDID File SizeFile Size MD5 ValueMD5 Value Last Modified TimeLast Modified Time Last Access TimeLast Access Time Expiration TimeExpiration Time Consistency Check MethodConsistency Check Method Interval Check TimeInterval Check Time
28
ALAL 系統元件設計系統元件設計– – Cache Manager Cache Manager (2/5)(2/5)
►內容一致性之維護 內容一致性之維護 – – 程式輸入值之類別程式輸入值之類別 Front-end InputFront-end Input
►客戶端透過客戶端透過 URLURL 參數值給予動態網頁應用程式輸入值 參數值給予動態網頁應用程式輸入值 ►無須進行快取文件之內容一致性的維護作業 無須進行快取文件之內容一致性的維護作業
Back-end InputBack-end Input►時間、後端資料庫等時間、後端資料庫等►需需 Cache ManagerCache Manager 來協助,以進行快取內容一致性來協助,以進行快取內容一致性之維護作業 之維護作業
29
ALAL 系統元件設計系統元件設計– – Cache Manager Cache Manager (3/5)(3/5)
►內容一致性之維護機制作業方式內容一致性之維護機制作業方式 Method for Regularly Changed ObjectsMethod for Regularly Changed Objects (( MTMT
11 ))►針對時間之針對時間之 Back-end InputBack-end Input 而設而設
Method for Irregularly Changed Objects with Method for Irregularly Changed Objects with NotificationNotification (( MT2MT2 ))►針對後端資料庫之針對後端資料庫之 Back-end InputBack-end Input 而設而設
Method for Irregularly Changed Objects Method for Irregularly Changed Objects without Notificationwithout Notification (( MT3MT3 ))►為了解決雖明知快取文件之內容有固定週期時間之變動,但為了解決雖明知快取文件之內容有固定週期時間之變動,但此週期時間卻無人知曉之窘況此週期時間卻無人知曉之窘況
30
ALAL 系統元件設計系統元件設計– – Cache Manager Cache Manager (4/5)(4/5)
While Check While Check {{
PNT++;PNT++;if page content change { CNT++; }if page content change { CNT++; }if (PNT == 5)if (PNT == 5){{
if(TCT == 0) // If Cache Manger doesn’t start to recordif(TCT == 0) // If Cache Manger doesn’t start to record{{ if(CNT == 0) { DED *= 2; } // Page doesn’t have any change.if(CNT == 0) { DED *= 2; } // Page doesn’t have any change.
else if(CNT == 5) { DED /= 2; } // Page changes every check time.else if(CNT == 5) { DED /= 2; } // Page changes every check time. else { TCT = CNT; HST = LMT; } // Start to recordelse { TCT = CNT; HST = LMT; } // Start to record }} elseelse {{ TCT += CNT;TCT += CNT;
DED = (LMT - HST) / TCT; // DED = Total time / Total ChangeDED = (LMT - HST) / TCT; // DED = Total time / Total Change }}
if(DED < 1) { DED = 1; }if(DED < 1) { DED = 1; }
PNT = CNT = 0;PNT = CNT = 0; }} sleep(DED); sleep(DED);
}}
PNTPNT :每次周期(檢查:每次周期(檢查 55 次所需的時間為一週期)內已經過的檢查次數次所需的時間為一週期)內已經過的檢查次數CNTCNT :每次周期內網頁內容變動的次數:每次周期內網頁內容變動的次數DEDDED :每次檢查網頁內容的間隔時間(:每次檢查網頁內容的間隔時間( SecondSecond ))LMTLMT :網頁內容最近變動的時間(:網頁內容最近變動的時間( UTCUTC ))TCTTCT :網頁內容變動的累計次數:網頁內容變動的累計次數HSTHST :開始進行網頁內容變動次數累計的時間(:開始進行網頁內容變動次數累計的時間( UTCUTC ))
31
ALAL 系統元件設計系統元件設計– – Cache Manager Cache Manager (5/5)(5/5)
►快取空間之置換快取空間之置換 (Replacement)(Replacement) 採用 採用 LRU (Least-Recently-Used) LRU (Least-Recently-Used) 置換策置換策略略
一旦達到一旦達到 95%95% 的快取空間置換上限的快取空間置換上限時,時, Cache ManagerCache Manager便會讀取存在於 便會讀取存在於 Cache Directory Cache Directory 中所有快取文件的 中所有快取文件的 Last Last Access TimeAccess Time ,從中找出久未被使用之快取,從中找出久未被使用之快取文件並刪除之,直到空間使用率達到文件並刪除之,直到空間使用率達到 90%90% 的的快取空間置換下限時,即會停止快取空間置換下限時,即會停止
32
ALAL 系統實作系統實作►OSOS :: LinuxLinux►Web ServerWeb Server :: ApacheApache►Web SwitchWeb Switch :: mod_rewritemod_rewrite 、、 PerlPerl►WADCWADC :: PHPPHP►Cache ManagerCache Manager :: ANSI CANSI C 、、 GCCGCC
33
ALAL 系統實作 系統實作 – – Cache Cache ManagerManager
Web ServerWeb ServerWeb ServerWeb Server Link -Link -listlist
Link -Link -listlist
Message Message QueueQueue
Message Message QueueQueue
Cache DirectoryCache DirectoryCache DirectoryCache Directory
Cache Cache ManagerManagerCache Cache
ManagerManager
WADCWADC(PHP etc.)(PHP etc.)WADCWADC
(PHP etc.)(PHP etc.)
1. Save1. Save 2. Send2. Send
3. Signal3. Signal
4. Get4. Get5. Get5. Get
6. Save6. Save7. Socket7. Socket
34
Server-Level Server-Level 動態網頁快取系統動態網頁快取系統ClientClientClientClient
Web ServerWeb ServerWeb ServerWeb Server
RequestRequestHandlerHandlerRequestRequestHandlerHandler
ResponseResponseOutput FilterOutput Filter
ResponseResponseOutput FilterOutput Filter
ResponseResponseHandlerHandler
ResponseResponseHandlerHandler
Cache ManagerCache ManagerCache ManagerCache Manager
Cache DirectoryCache DirectoryCache DirectoryCache Directory
35
SLSL 系統元件設計 系統元件設計 – – <CACHE><CACHE>
►<CACHE><CACHE> 之初始概念之初始概念
<HTML><BODY><H3>Welcome ! <? echo $name; ?></H3>Today is <B><? echo date("F j, Y"); ?></B></BODY></HTML>
<HTML><BODY><H3>Welcome ! Morpheus</H3>Today is <B>May 12, 2003</B></BODY></HTML>
Welcome ! Morpheus
Today is May 12, 2003
(a) welcome.php (b) Html output of welcome.php
(c) Final view in client browser
D1
D2
D1
D2
D1
D2
Static Part Dynamic Part Full Page
36
SLSL 系統元件設計 系統元件設計 – – <CACHE><CACHE>► <CACHE><CACHE>語法語法
► 使用範例使用範例
<<CACHE CT=”CACHE CT=”cache-typecache-type” CM=”” CM=”cache-consistency-methodcache-consistency-method” ” CP=”CP=”cache-periodcache-period” CO=”” CO=”cache-control-optioncache-control-option””>>
……………………Dynamic-ContentDynamic-Content……………………
</</CACHECACHE> >
37
SLSL 系統元件設計 系統元件設計 – – Request Request HandlerHandler
Request HandlerRequest HandlerRequest HandlerRequest Handler
Request from ClientRequest from ClientRequest from ClientRequest from Client
Type A or B Type A or B URLURL
Type A or B Type A or B URLURL
Request from Request from Client & Cache Client & Cache
ManagerManager( RCCM )( RCCM )
Request from Request from Client & Cache Client & Cache
ManagerManager( RCCM )( RCCM )
Have IMS Have IMS HeaderHeader
Have IMS Have IMS HeaderHeader
Cache File Cache File ExistExist
Cache File Cache File ExistExist
After First After First Request from Request from
client , file Exist client , file Exist , Not expired, Not expired( AFREN )( AFREN )
After First After First Request from Request from
client , file Exist client , file Exist , Not expired, Not expired( AFREN )( AFREN )
First Request , First Request , File Exist File Exist ( FRFE )( FRFE )
First Request , First Request , File Exist File Exist ( FRFE )( FRFE )
After First After First Request from Request from
client , file Exist client , file Exist , Expired, Expired
( AFREE )( AFREE )
After First After First Request from Request from
client , file Exist client , file Exist , Expired, Expired
( AFREE )( AFREE )
First Request , First Request , File Not exist File Not exist
( FRFN )( FRFN )
First Request , First Request , File Not exist File Not exist
( FRFN )( FRFN )
File has been File has been modifiedmodified
File has been File has been modifiedmodified
AA
BB YesYes
NoNo
After First After First Request from Request from
client , file Not client , file Not existexist
( AFRN )( AFRN )
After First After First Request from Request from
client , file Not client , file Not existexist
( AFRN )( AFRN )
Cache File Cache File ExistExist
Cache File Cache File ExistExist
YesYes
YesYes
YesYesNoNo NoNo NoNo
Response HandlerResponse HandlerResponse HandlerResponse Handler
38
SLSL 系統元件設計 系統元件設計 – – Response Response HandlerHandler
Response HandlerResponse HandlerResponse HandlerResponse Handler
Request HandlerRequest HandlerRequest HandlerRequest Handler
Type B to Type A URLType B to Type A URLType B to Type A URLType B to Type A URL
Web Application ProcessingWeb Application ProcessingWeb Application ProcessingWeb Application Processing
HTML HTML PagePage
HTML HTML PagePage
Response Output FilterResponse Output FilterResponse Output FilterResponse Output Filter
Get information from Get information from Cache Directory and Cache Directory and
Cache ManagerCache Manager
Get information from Get information from Cache Directory and Cache Directory and
Cache ManagerCache Manager
Response the request Response the request file plus HTTP file plus HTTP
Cache-Control HeaderCache-Control Header
Response the request Response the request file plus HTTP file plus HTTP
Cache-Control HeaderCache-Control Header
Response with Response with HTTP Header – HTTP Header –
304 Not 304 Not ModifiedModified
Response with Response with HTTP Header – HTTP Header –
304 Not 304 Not ModifiedModified
AFRENAFREN FRFEFRFE AFREEAFREE RCCMRCCM
FRFNFRFN AFRNAFRN
39
SLSL 系統元件設計 系統元件設計 – – Response Response Output FilterOutput Filter
Response Output FilterResponse Output FilterResponse Output FilterResponse Output Filter
Response HandlerResponse HandlerResponse HandlerResponse Handler
Response to ClientResponse to ClientResponse to ClientResponse to Client
Have <CACHE>Have <CACHE>Have <CACHE>Have <CACHE>
Separate and construct the dynamic and Separate and construct the dynamic and static contentstatic content
Separate and construct the dynamic and Separate and construct the dynamic and static contentstatic content
Collect information then save to Cache Collect information then save to Cache Directory and Cache ManagerDirectory and Cache Manager
Collect information then save to Cache Collect information then save to Cache Directory and Cache ManagerDirectory and Cache Manager
Response the request file and HTTP Response the request file and HTTP Cache-Control HeaderCache-Control Header
Response the request file and HTTP Response the request file and HTTP Cache-Control HeaderCache-Control Header
Pass through all informationPass through all informationPass through all informationPass through all information
AFRENAFRENFRFEFRFE 、、 AFREEAFREE RCCMRCCM 、、 FRFNFRFN 、、 AFRNAFRN
NoNo YesYes
40
系統效能評估系統效能評估►實驗平台實驗平台►實驗項目實驗項目
客戶端等待時間客戶端等待時間、、伺服器處理能力伺服器處理能力 網路傳輸量網路傳輸量 網頁內容一致性網頁內容一致性 與其它動態網頁快取系統之比較與其它動態網頁快取系統之比較
41
實驗平台實驗平台Web ServerWeb Server
HardwareHardware SoftwareSoftware
CPUCPU Intel P4 1.6GMHzIntel P4 1.6GMHz OSOS Red Hat Linux 8.0Red Hat Linux 8.0
RAMRAM 256MB SDRAM256MB SDRAM Web ServerWeb Server Apache 2.0.45Apache 2.0.45
HDDHDD IBM-DPTA-372050 ATA DISKIBM-DPTA-372050 ATA DISK mod_prel 1.99mod_prel 1.99
NICNIC D-link 530TX rev BD-link 530TX rev B Web App Script LangWeb App Script Lang PHP 4.3.1PHP 4.3.1
SQL ServerSQL Server MySQL 3.23.55MySQL 3.23.55
Proxy ServerProxy Server
HardwareHardware SoftwareSoftware
CPUCPU Intel PIII 550MHzIntel PIII 550MHz OSOS Red Hat Linux 8.0Red Hat Linux 8.0
RAMRAM 128MB SDRAM128MB SDRAM Proxy ServerProxy Server Squid-2.4.STABLE7-4Squid-2.4.STABLE7-4
HDDHDD IBM-DPTA-372050 ATA DISKIBM-DPTA-372050 ATA DISK
NICNIC D-link 530TX rev BD-link 530TX rev B
ClientClient
HardwareHardware SoftwareSoftware
CPUCPU Intel PIII 550MHzIntel PIII 550MHz OSOS Red Hat Linux 8.0Red Hat Linux 8.0
RAMRAM 128MB SDRAM128MB SDRAM Measurement ToolMeasurement Tool httperf-0.8httperf-0.8
HDDHDD IBM-DPTA-372050 ATA DISKIBM-DPTA-372050 ATA DISK
NICNIC D-link 530TX rev BD-link 530TX rev B
42
實驗 實驗 – – 客戶端等待時間客戶端等待時間、、伺服器處伺服器處理能力 理能力 (1/3)(1/3)
►實驗情境實驗情境 令網頁伺服器執行一極為耗用伺服器資源之動態網頁應令網頁伺服器執行一極為耗用伺服器資源之動態網頁應用程式,用以模擬一伺服器端正處於高負載量之情境,用程式,用以模擬一伺服器端正處於高負載量之情境,藉以測知 藉以測知 Application-Level Application-Level 動態網頁快取系統在此動態網頁快取系統在此情境下,可協助伺服器端縮短多少客戶端之原先等待時情境下,可協助伺服器端縮短多少客戶端之原先等待時間,又可提升多少網頁伺服器之原先處理能力間,又可提升多少網頁伺服器之原先處理能力
►實驗組別實驗組別 PHPPHP FRFR (( First RequestFirst Request )) AFRAFR (( After First RequestAfter First Request ))
for ( i=0 ; i < x ; i++ )for ( i=0 ; i < x ; i++ ){{ result = power ( square ( i ) );result = power ( square ( i ) );}}print result;print result;
43
實驗 實驗 – – 客戶端等待時間客戶端等待時間、、伺服器處伺服器處理能力 理能力 (2/3)(2/3)
Web Server Thoughput -- CPU-Bound WebApps
0.93
0.30.82
0.40.24
811.43 812.89 817.06 806.51 814.69 818.25 821.67
0.10.10.20.2
0.4
0.20.10.10.110.1
1
10
100
1000
100000 200000 300000 400000 500000 600000 700000
variable x
Ser
ver
Acc
epta
ble
Req
ues
t P
er S
eco
nd
PHP FR AFR
10 conn , 1call/conn
Web Server Thoughput -- CPU-Bound WebApps
0.93
0.30.82
0.40.24
811.43 812.89 817.06 806.51 814.69 818.25 821.67
0.10.10.20.2
0.4
0.20.10.10.110.1
1
10
100
1000
100000 200000 300000 400000 500000 600000 700000
variable x
Ser
ver
Acc
epta
ble
Req
ues
t P
er S
eco
nd
PHP FR AFR
10 conn , 1call/conn
44
實驗 實驗 – – 客戶端等待時間客戶端等待時間、、伺服器處伺服器處理能力 理能力 (3/3)(3/3)
Average Access Latency -- CPU-Bound WebApps
1096.59
2456.93
3776.88
5051.33
6480.29
7861.43
9216.05
1255.43
2644.88
3984.78
5355.32
6792.91
8091.43
9461.36
1.24 1.24 1.23 1.25 1.23 1.22 1.220
1000
2000
3000
4000
5000
6000
7000
8000
9000
10000
100000 200000 300000 400000 500000 600000 700000
variable x
Mil
lise
con
ds
PHP FR AFR
10 conn , 1call/conn
Average Access Latency -- CPU-Bound WebApps
1096.59
2456.93
3776.88
5051.33
6480.29
7861.43
9216.05
1255.43
2644.88
3984.78
5355.32
6792.91
8091.43
9461.36
1.24 1.24 1.23 1.25 1.23 1.22 1.220
1000
2000
3000
4000
5000
6000
7000
8000
9000
10000
100000 200000 300000 400000 500000 600000 700000
variable x
Mil
lise
con
ds
PHP FR AFR
10 conn , 1call/conn
45
實驗 實驗 – – 網路傳輸量 網路傳輸量 (1/2)(1/2)
►實驗情境實驗情境 取得現今二個相當熱門的網站內之動態網頁,並嘗試將取得現今二個相當熱門的網站內之動態網頁,並嘗試將此二動態網頁中之動、靜態內容分離,用以模擬若是由 此二動態網頁中之動、靜態內容分離,用以模擬若是由 Server-Level Server-Level 動態網頁快取系統來處理此二動態網頁,動態網頁快取系統來處理此二動態網頁,可減少多少原先需使用之網路傳輸量可減少多少原先需使用之網路傳輸量
news.yahoo.comnews.yahoo.comnews.yahoo.comnews.yahoo.com DailyStock.comDailyStock.comDailyStock.comDailyStock.com
46
實驗 實驗 – – 網路傳輸量 網路傳輸量 (2/2)(2/2)
news.yahoo.com
41.202
29.171
15.772
0
5
10
15
20
25
30
35
40
45
Fil
e S
ize
(KB
)
Original
Static
Dynamic
DailyStocks.com
253.767
138.563
12.574
0
50
100
150
200
250
300
Fil
e S
ize
(KB
)
Original
Static
Dynamic
news.yahoo.com
41.202
29.171
15.772
0
5
10
15
20
25
30
35
40
45
Fil
e S
ize
(KB
)
Original
Static
Dynamic
DailyStocks.com
253.767
138.563
12.574
0
50
100
150
200
250
300
Fil
e S
ize
(KB
)
Original
Static
Dynamic
news.yahoo.com
41.202
29.171
15.772
0
5
10
15
20
25
30
35
40
45
Fil
e S
ize
(KB
)
Original
Static
Dynamic
DailyStocks.com
253.767
138.563
12.574
0
50
100
150
200
250
300
Fil
e S
ize
(KB
)
Original
Static
Dynamic
news.yahoo.com
41.202
29.171
15.772
0
5
10
15
20
25
30
35
40
45
Fil
e S
ize
(KB
)
Original
Static
Dynamic
DailyStocks.com
253.767
138.563
12.574
0
50
100
150
200
250
300
Fil
e S
ize
(KB
)
Original
Static
Dynamic
47
實驗 實驗 – – 網頁內容一致性 網頁內容一致性 (1/6)(1/6)
►實驗情境實驗情境 實作一個提供即時資訊之新聞網站,並以眾多客戶端在實作一個提供即時資訊之新聞網站,並以眾多客戶端在同一時間內對此網站提出網頁瀏覽之請求,用以模擬一同一時間內對此網站提出網頁瀏覽之請求,用以模擬一伺服器端有著極為高度之網頁內容更新率與擁有大量請伺服器端有著極為高度之網頁內容更新率與擁有大量請求同時到來之情境,藉以測知 求同時到來之情境,藉以測知 Application-Level Application-Level 動態動態網頁快取系統在此情境下,可否持續維持快取文件之內網頁快取系統在此情境下,可否持續維持快取文件之內容一致性,又可縮短多少客戶端之等待時間與提升多少容一致性,又可縮短多少客戶端之等待時間與提升多少伺服器之處理能力 伺服器之處理能力
48
實驗 實驗 – – 網頁內容一致性 網頁內容一致性 (2/6)(2/6)
Yes
ApacheApache
MySQL(Data changes every 30 secs)
MySQL(Data changes every 30 secs)
simCachesimCache
Cache DirectoryCache Directory
PHPWADC
PHPWADC
Web SwitchWeb Switch
No
Client ( random request N times
every 1 sec)
Client ( random request N times
every 1 sec)
simCache.logsimCache.log
result.logresult.log
Write
Compare
Type B
Cache ManagerCache Manager
Type A
UpdateLog
Write cmr file
Update Notify
ResponseResponse
Notify that the data has been changed
MT2 實驗配置
Yes
ApacheApache
MySQL(Data changes every 30 secs)
MySQL(Data changes every 30 secs)
simCachesimCache
Cache DirectoryCache Directory
PHP WADC
PHP WADC
Web SwitchWeb Switch
No
Client ( random request N times
every 1 sec)
Client ( random request N times
every 1 sec)
simCache.logsimCache.log
result.logresult.log
Write
Compare
Type B
Cache Manager (process every 30 secs)Cache Manager (process every 30 secs)
Type A
UpdateLog
Write cmr file
Compare
Update existing page
Notify
ResponseResponse
MT1 實驗配置
49
實驗 實驗 – – 網頁內容一致性 網頁內容一致性 (3/6)(3/6)
Average Access Latency -- Exp Consistency
6.86
15.9419.59
29.7336.49
50.64 54.98 59.0575.24
4.11
6.077.19
9.5311.66
15.3 16.37 17.1821.23
4.15
6 6.86
9.7411.52
15.41 16.51 17.2221.09
1
10
100
10 40 50 80 100 140 150 160 200
Client Request Number Per Second
Mil
liS
eco
nd
PHP MT1 MT2
Average Access Latency -- Exp Consistency
6.86
15.9419.59
29.7336.49
50.64 54.98 59.0575.24
4.11
6.077.19
9.5311.66
15.3 16.37 17.1821.23
4.15
6 6.86
9.7411.52
15.41 16.51 17.2221.09
1
10
100
10 40 50 80 100 140 150 160 200
Client Request Number Per Second
Mil
liS
eco
nd
PHP MT1 MT2
50
實驗 實驗 – – 網頁內容一致性 網頁內容一致性 (4/6)(4/6)
Average CPU Loading -- Exp Consistency
3.69
14.2717.91
28.59
35.77
50.8754.49
58.25
72.43
10.8113.40
18.53 19.82 21.2526.42
6.9710.95
13.6618.52 19.90 21.24
26.34
1.87
6.845.58
5.732.040
10
20
30
40
50
60
70
80
10 40 50 80 100 140 150 160 200
Client Request Number Per Second
Serv
er C
PU
Load
ing
(%)
PHP MT1 MT2
Average CPU Loading -- Exp Consistency
3.69
14.2717.91
28.59
35.77
50.8754.49
58.25
72.43
10.8113.40
18.53 19.82 21.2526.42
6.9710.95
13.6618.52 19.90 21.24
26.34
1.87
6.845.58
5.732.040
10
20
30
40
50
60
70
80
10 40 50 80 100 140 150 160 200
Client Request Number Per Second
Serv
er C
PU
Load
ing
(%)
PHP MT1 MT2
51
實驗 實驗 – – 網頁內容一致性 網頁內容一致性 (5/6)(5/6)
MT3 -- DB Change every 5 Secs -- Exp Consistency
0
5
10
15
20
25
30
35
Passed Time (Secs)
Cac
hem
gr C
heck
Fre
q(S
ecs)
MT3 -- DB Change every 15 Secs -- Exp Consistency
0
5
10
15
20
25
30
35
Passed Time (Secs)
Cac
hem
gr C
heck
Fre
q(S
ecs)
MT3 -- DB Change every 90 Secs -- Exp Consistency
0102030405060708090
100
Passed Time (Secs)
Cac
hem
gr C
heck
Fre
q (S
ecs)
MT3 -- DB Change every 300 Secs -- Exp Consistency
0
50
100
150
200
250
300
350
Passed Time (Secs)
Cac
hem
gr C
heck
Fre
q(S
ecs)
MT3 -- DB Change every 5 Secs -- Exp Consistency
0
5
10
15
20
25
30
35
Passed Time (Secs)
Cac
hem
gr C
heck
Fre
q(S
ecs)
MT3 -- DB Change every 15 Secs -- Exp Consistency
0
5
10
15
20
25
30
35
Passed Time (Secs)
Cac
hem
gr C
heck
Fre
q(S
ecs)
MT3 -- DB Change every 90 Secs -- Exp Consistency
0102030405060708090
100
Passed Time (Secs)
Cac
hem
gr C
heck
Fre
q (S
ecs)
MT3 -- DB Change every 300 Secs -- Exp Consistency
0
50
100
150
200
250
300
350
Passed Time (Secs)
Cac
hem
gr C
heck
Fre
q(S
ecs)
MT3 -- DB Change every 5 Secs -- Exp Consistency
0
5
10
15
20
25
30
35
Passed Time (Secs)
Cac
hem
gr C
heck
Fre
q(S
ecs)
MT3 -- DB Change every 15 Secs -- Exp Consistency
0
5
10
15
20
25
30
35
Passed Time (Secs)
Cac
hem
gr C
heck
Fre
q(S
ecs)
MT3 -- DB Change every 90 Secs -- Exp Consistency
0102030405060708090
100
Passed Time (Secs)
Cac
hem
gr C
heck
Fre
q (S
ecs)
MT3 -- DB Change every 300 Secs -- Exp Consistency
0
50
100
150
200
250
300
350
Passed Time (Secs)
Cac
hem
gr C
heck
Fre
q(S
ecs)
MT3 -- DB Change every 5 Secs -- Exp Consistency
0
5
10
15
20
25
30
35
Passed Time (Secs)
Cac
hem
gr C
heck
Fre
q(S
ecs)
MT3 -- DB Change every 15 Secs -- Exp Consistency
0
5
10
15
20
25
30
35
Passed Time (Secs)
Cac
hem
gr C
heck
Fre
q(S
ecs)
MT3 -- DB Change every 90 Secs -- Exp Consistency
0102030405060708090
100
Passed Time (Secs)
Cac
hem
gr C
heck
Fre
q (S
ecs)
MT3 -- DB Change every 300 Secs -- Exp Consistency
0
50
100
150
200
250
300
350
Passed Time (Secs)
Cac
hem
gr C
heck
Fre
q(S
ecs)
52
實驗 實驗 – – 網頁內容一致性 網頁內容一致性 (6/6)(6/6)Average MT1 Fresh Hit Ratio -- Exp ConsistencyAverage MT1 Fresh Hit Ratio -- Exp Consistency
MissMiss HitHit
RequestRequestss
/Sec/Sec-- FreshFresh StaleStale
Average Average FreshFresh
Hit RatioHit Ratio
1010 1010 57915791 199199 0.9667780.966778
4040 1010 2317723177 813813 0.9661110.966111
5050 1010 2901129011 979979 0.9673560.967356
8080 1010 4615546155 18351835 0.9617630.961763
100100 1313 5814958149 18381838 0.9693620.969362
140140 1010 8102581025 29652965 0.9646980.964698
150150 1515 8701687016 29692969 0.9670060.967006
160160 1111 9236992369 36203620 0.9622870.962287
200200 1010 116204116204 37863786 0.9684470.968447
Total Average Fresh Hit RatioTotal Average Fresh Hit Ratio 0.9659780.965978
Average MT2 Fresh Hit Ratio -- Exp ConsistencyAverage MT2 Fresh Hit Ratio -- Exp Consistency
MissMiss HitHit
RequestRequestss
/Sec/Sec-- FreshFresh StaleStale
Average Average FreshFresh
Hit RatioHit Ratio
1010 1010 59895989 11 0.9998330.999833
4040 1010 2398923989 11 0.9999580.999958
5050 1010 2997629976 1414 0.9995330.999533
8080 1010 4796847968 2222 0.9995420.999542
100100 1010 5996059960 3030 0.9995230.999523
140140 1010 8398683986 44 0.9999520.999952
150150 1515 8998289982 33 0.9999670.999967
160160 1010 9594195941 4949 0.9994930.999493
200200 1717 119895119895 8888 0.9992670.999267
Total Average Fresh Hit RatioTotal Average Fresh Hit Ratio 0.9996710.999671
53
實驗 實驗 – – 與其它動態網頁快取系統之與其它動態網頁快取系統之比較 比較 (1/4)(1/4)
►實驗情境實驗情境 將將 Application-LevelApplication-Level 動態網頁快取系統與其它動態網動態網頁快取系統與其它動態網頁快取系統一同模擬比較,以了解這些系統於其快取程頁快取系統一同模擬比較,以了解這些系統於其快取程序上之差異,與效率上之差別 序上之差異,與效率上之差別
►實驗對象實驗對象 Reverse ProxyReverse Proxy CachumaCachuma phpCachephpCache
54
實驗 實驗 – – 與其它動態網頁快取系統之與其它動態網頁快取系統之比較 比較 (2/4)(2/4)
Average Access Latency -- Exp Prosim
1
10
100
1000
10000
10 20 30 40 50 60 70 80 90 100Client Request Number Per Second
Mil
lise
co
nd
Reverse Proxy - FR Reverse Proxy - AFR Cachuma - FRCachuma - AFR phpCache - FR phpCache - AFROur Resarch - FR Our Resarch - AFR
Average Access Latency -- Exp Prosim
1
10
100
1000
10000
10 20 30 40 50 60 70 80 90 100Client Request Number Per Second
Mil
lise
co
nd
Reverse Proxy - FR Reverse Proxy - AFR Cachuma - FRCachuma - AFR phpCache - FR phpCache - AFROur Resarch - FR Our Resarch - AFR
55
實驗 實驗 ––與其它動態網頁快取系統之比與其它動態網頁快取系統之比較 較 (3/4)(3/4)
22
15
29
23
66
58
2624
39
33
7268
2527
53
41
8179
23
15
31
23
72
58
0
10
20
30
40
50
60
70
80
90
10K - FR 10K - AFR 100K - FR 100K - AFR 500K - FR 500K - AFR
Mil
liS
eco
nd
Reverse Proxy
Cachuma
phpCache
Our Research
Byte
22
15
29
23
66
58
2624
39
33
7268
2527
53
41
8179
23
15
31
23
72
58
0
10
20
30
40
50
60
70
80
90
10K - FR 10K - AFR 100K - FR 100K - AFR 500K - FR 500K - AFR
Mil
liS
eco
nd
Reverse Proxy
Cachuma
phpCache
Our Research
Byte
22
15
29
23
66
58
2624
39
33
7268
2527
53
41
8179
23
15
31
23
72
58
0
10
20
30
40
50
60
70
80
90
10K - FR 10K - AFR 100K - FR 100K - AFR 500K - FR 500K - AFR
Mil
liS
eco
nd
Reverse Proxy
Cachuma
phpCache
Our Research
Byte
22
15
29
23
66
58
2624
39
33
7268
2527
53
41
8179
23
15
31
23
72
58
0
10
20
30
40
50
60
70
80
90
10K - FR 10K - AFR 100K - FR 100K - AFR 500K - FR 500K - AFR
Mil
liS
eco
nd
Reverse Proxy
Cachuma
phpCache
Our Research
Byte
56
實驗 實驗 ––與其它動態網頁快取系統之比與其它動態網頁快取系統之比較 較 (4/4)(4/4)
57
結論結論► Application-Level Application-Level 動態網頁快取系統之優點動態網頁快取系統之優點
快速之回應時間、低度之快速之回應時間、低度之 CPUCPU 使用率、大量之客戶端請使用率、大量之客戶端請求處理能力、有效之內容一致性維護機制、簡潔之處理求處理能力、有效之內容一致性維護機制、簡潔之處理與搜尋快取文件程序與搜尋快取文件程序
► Server-Level Server-Level 動態網頁快取系統之優點動態網頁快取系統之優點 小幅之網路傳輸量小幅之網路傳輸量
►成功達成本研究之研究目的 成功達成本研究之研究目的 ––縮短客戶端等待時間、提升伺服器處理能力、縮短客戶端等待時間、提升伺服器處理能力、
減輕網路壅塞情況 減輕網路壅塞情況
58
未來展望未來展望►<CACHE><CACHE> 功能之擴充功能之擴充►動態網頁之預取(動態網頁之預取( PrefetchPrefetch ))►動態網頁程式碼之快取(動態網頁程式碼之快取( Code CachingCode Caching ))
59
Q & AQ & A
Thank You Thank You
60
Application based exampleApplication based exampleWeb Application
Web Application
Static
Web Application
Dynamic
Static.html Function.js Data.js
圖 1 :網頁應用程式架構圖
61
Application based exampleApplication based example<? $K = array("Key 1","Key 2");$V = array("Value 1","Value 2");Function Show($I) {global $K, $V;echo "<TR><TD>$K[$I]</TD><TD>$V[$I]</TD></TR>";}?><HTML><HEAD><TITLE>Example </TITLE></HEAD><BODY><TABLE><? for($I=0;$I<2;$I++) Show($I); ?></TABLE></BODY></HTML>
圖 2 : Original.php
62
Application based exampleApplication based example
<HTML><HEAD><TITLE>Example </TITLE></HEAD><BODY><TABLE><TR><TD>Key 1</TD><TD>Value 1 </TD></TR><TR><TD>Key 2</TD><TD>Value 2</TD></TR></TABLE></BODY></HTML>
圖 3 : Original.html
63
Application based exampleApplication based example<? $data_file = fopen("Data.js","w");fwrite($data_file,"var K = new Array(\"Key 1\",\"Key2\");var V = new Array(\"Value 1\",\"Value 2\");");?>
圖 4 : Dynamic.php
64
Application based exampleApplication based example<HTML><HEAD><TITLE>Example </TITLE><SCRIPT SRC=Data.js></SCRIPT><SCRIPT SRC=Function.js></SCRIPT></HEAD><BODY><TABLE><SCRIPT LANGUAGE=JavaScript> for(I=0; I<2;I++) Show(I);</Script></TABLE></BODY></HTML>
圖 5 : Static.html
65
Application based exampleApplication based example<?$html_file = fopen("Static.html","w");$function_file = fopen("Function.js","w");fwrite($function_file,"function Show(Loop) {document.write (\"<TR><TD>\"+K[I]+\"</TD><TD>\"+V[I]+\"</TD></TR>\");}");fwrite($html_file,"<HTML><HEAD><TITLE>Example </TITLE><SCRIPT SRC=Data.js></SCRIPT><SCRIPT SRC=Function.js></SCRIPT></HEAD><BODY><TABLE><SCRIPT LANGUAGE=JavaScript> for(I=0; I<2;I++) Show(I);</Script></TABLE></BODY></HTML>”); fclose($html_file); fclose($function_file); ?>
圖 6 : Static.php
66
Application based exampleApplication based examplefunction Show(I) { document.write ("<TR><TD>"+K[I]+"</TD><TD>"+V[I]+"</TD></TR>");}
圖 7 : Function.js
var K = Array("Key 1","Key 2");var V = Array("Value 1","Value 2");
圖 8 :Data.js