畢業(yè)設(shè)計(jì)外文資料翻譯-PHP和JSP作為服務(wù)器腳本語(yǔ)言的性能比較_第1頁(yè)
畢業(yè)設(shè)計(jì)外文資料翻譯-PHP和JSP作為服務(wù)器腳本語(yǔ)言的性能比較_第2頁(yè)
畢業(yè)設(shè)計(jì)外文資料翻譯-PHP和JSP作為服務(wù)器腳本語(yǔ)言的性能比較_第3頁(yè)
畢業(yè)設(shè)計(jì)外文資料翻譯-PHP和JSP作為服務(wù)器腳本語(yǔ)言的性能比較_第4頁(yè)
畢業(yè)設(shè)計(jì)外文資料翻譯-PHP和JSP作為服務(wù)器腳本語(yǔ)言的性能比較_第5頁(yè)
已閱讀5頁(yè),還剩10頁(yè)未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、畢業(yè)設(shè)計(jì)外文資料翻譯學(xué) 院: 專業(yè)班級(jí): 學(xué)生姓名: 學(xué) 號(hào): 指導(dǎo)教師: 外文出處:書名:Springer Berlin Heidelberg 頁(yè)碼:164-182 作者:S Trent,M Tatsubori,T Suzumura 附 件:1.外文資料翻譯譯文; 2.外文原文 指導(dǎo)教師評(píng)語(yǔ):該英文資料選擇合理,與畢業(yè)設(shè)計(jì)報(bào)告相關(guān)度比較高。專業(yè)術(shù)語(yǔ)、詞匯翻譯的準(zhǔn)確度達(dá)到要求,體現(xiàn)了較高的專業(yè)英語(yǔ)應(yīng)用水平。外文翻譯與研究課題關(guān)系密切,翻譯工作能夠嚴(yán)格按照規(guī)定,達(dá)到考核、提高學(xué)生英語(yǔ)應(yīng)用水平的目的,完成要求。 簽名: 2015年 10月14日1外文資料翻譯譯文PHP和JSP作為服務(wù)器腳本語(yǔ)言的性

2、能比較摘要 動(dòng)態(tài)腳本語(yǔ)言PHP已經(jīng)成為實(shí)現(xiàn)輕量級(jí)的Web應(yīng)用程序非常受歡迎,被廣泛用作服務(wù)器端腳本語(yǔ)言的Web服務(wù)器。對(duì)比PHP和JSP的性能,為此,我們使用SPECweb2005基準(zhǔn),它提供了PHP和JSP實(shí)施了三個(gè)應(yīng)用場(chǎng)景。本文介紹和對(duì)比上采用了時(shí)下流行的Web服務(wù)器Apache和PHP的Lighttpd和JSP的不同配置進(jìn)行SPECweb2005性能基準(zhǔn)測(cè)試的結(jié)果。盡管在微基準(zhǔn)測(cè)試發(fā)現(xiàn)PHP引擎解釋執(zhí)行開(kāi)銷,SPECweb2005基準(zhǔn)的實(shí)驗(yàn)結(jié)果得到了Web服務(wù)器的實(shí)施者有價(jià)值的性能數(shù)據(jù)。腳本語(yǔ)言運(yùn)行時(shí)的效率仍然重要的終端到終端的性能。然而,一次精心架構(gòu)和調(diào)整,語(yǔ)言運(yùn)行時(shí)少的瓶頸不是Web

3、服務(wù)器的性能本身。關(guān)鍵詞:PHP,JSP,SPECweb,標(biāo)桿,Web服務(wù)器。1簡(jiǎn)介動(dòng)態(tài)腳本語(yǔ)言PHP(PHP超文本預(yù)處理器)已經(jīng)成為非常流行的輕量級(jí)Web執(zhí)行應(yīng)用程序,并廣泛用于訪問(wèn)數(shù)據(jù)庫(kù)和其他中間件。2007年10月流行的Apache模塊安全空間進(jìn)行的調(diào)查表明,37%的Apache服務(wù)器支持PHP功能,以10個(gè)百分點(diǎn)使它成為最流行的Apache模塊。企業(yè)正迅速實(shí)現(xiàn)與動(dòng)態(tài)腳本語(yǔ)言,如PHP的面向服務(wù)的體系結(jié)構(gòu)環(huán)境的強(qiáng)大組合。然而,我們相信仍然有重要的性能問(wèn)題涉及到PHP,它仍有待于被調(diào)查。本文重點(diǎn)介紹了動(dòng)態(tài)腳本語(yǔ)言的使用來(lái)實(shí)現(xiàn)Web服務(wù)器的前端接口。與此對(duì)應(yīng)的方式,該行業(yè)標(biāo)準(zhǔn)的Web服務(wù)器性

4、能的基準(zhǔn)SPECweb2005利用PHP和JSP(JavaServer頁(yè)面)。在這種情況下,腳本是用于執(zhí)行動(dòng)態(tài)頁(yè)面生成,而不是復(fù)雜的業(yè)務(wù)邏輯的實(shí)現(xiàn)。與此相反的傳統(tǒng)用途是基于JSP的復(fù)雜的業(yè)務(wù)邏輯實(shí)現(xiàn)。雖然有許多動(dòng)態(tài)網(wǎng)頁(yè)內(nèi)容的研究,本文補(bǔ)充了這些研究的詳細(xì)分析,重點(diǎn)在于PHP中。例如,下面就CGI(通用網(wǎng)關(guān)接口)基于Web服務(wù)器的動(dòng)態(tài)內(nèi)容由耶格爾麥格拉思可追溯到1995年的性能研究,研究人員和從業(yè)者一直在研究最近的動(dòng)態(tài)的WebContent技術(shù)性能。這些作品,然而,處理應(yīng)用程序方案在servlet前端實(shí)現(xiàn)相對(duì)復(fù)雜的業(yè)務(wù)邏輯。雖然華納和沃利也使用PHP與SPECweb2005,以作者所知的重要性,

5、本文是首次發(fā)布了使用PHP和JSP的SPECweb2005實(shí)驗(yàn)結(jié)果的詳細(xì)分析。PHP和JSP的性能的詳細(xì)分析是基于本文件所提供的SPECweb2005,使設(shè)計(jì)者和實(shí)施者了解Web服務(wù)器的相對(duì)性能,并通過(guò)把不同版本的PHP和JSP進(jìn)行配置。2多層Web服務(wù)器架構(gòu):使用PHP/JSP的輕量級(jí)前端開(kāi)發(fā)人員通常使用PHP來(lái)實(shí)現(xiàn)一個(gè)生成動(dòng)態(tài)Web內(nèi)容的前端界面,這與Web服務(wù)器軟件和后端服務(wù)器相結(jié)合,提供動(dòng)態(tài)內(nèi)容。該網(wǎng)站的服務(wù)器直接處理靜態(tài)內(nèi)容并轉(zhuǎn)發(fā)請(qǐng)求動(dòng)態(tài)內(nèi)容生成動(dòng)態(tài)內(nèi)容。后端服務(wù)器支持動(dòng)態(tài)內(nèi)容生成,執(zhí)行代碼來(lái)實(shí)現(xiàn)一個(gè)網(wǎng)站和商店的動(dòng)態(tài)狀態(tài)的業(yè)務(wù)邏輯。后端服務(wù)器可以作為一個(gè)直接的數(shù)據(jù)庫(kù)來(lái)實(shí)現(xiàn),或者可能更

6、復(fù)雜的服務(wù)器處理該網(wǎng)站的業(yè)務(wù)邏輯。前端的執(zhí)行可能有所不同于重量級(jí)的業(yè)務(wù)邏輯程序來(lái)處理從后端服務(wù)器接收輕量級(jí)客戶端的內(nèi)容。本文重點(diǎn)介紹多層Web站點(diǎn)開(kāi)發(fā)利用這種由一個(gè)或多個(gè)重量級(jí)后端層支持輕量級(jí)的前端。當(dāng)考慮到面向服務(wù)的環(huán)境中PHP腳本用來(lái)實(shí)現(xiàn)提供其他地方的一個(gè)“混搭”的服務(wù),這種假設(shè)是合理的。除了簡(jiǎn)單的網(wǎng)站情況下,例如公告板中PHP腳本只是一個(gè)包裝到一個(gè)數(shù)據(jù)庫(kù)。在本文中所描述的場(chǎng)景中,動(dòng)態(tài)內(nèi)容生成器提供動(dòng)態(tài)內(nèi)容頁(yè)組成,除了客戶端實(shí)現(xiàn)。它通過(guò)使用標(biāo)準(zhǔn)協(xié)議諸如HTTP或應(yīng)用程序/中間件特定協(xié)議連接到后端服務(wù)器。JSP技術(shù)可以被認(rèn)為是對(duì)PHP在執(zhí)行這些前端的一種選擇。雖然它是Java Servlet

7、的框架的一部分,開(kāi)發(fā)人員通常使用JSP來(lái)實(shí)現(xiàn)輕量級(jí)前端。PHP和JSP允許開(kāi)發(fā)人員可以編寫HTML嵌入代碼。事實(shí)上,雖然PHP和Java之間有著固有的不同之處,但PHP的腳本和JSP文件在使用上的差異可能會(huì)非常相似。在這份文件中詳細(xì)介紹了實(shí)驗(yàn)的目的是衡量結(jié)合諸如Apache和Lighttpd的流行Web服務(wù)器,使用PHP和JSP編寫的輕量級(jí)前端動(dòng)態(tài)內(nèi)容生成器性能。此Web服務(wù)器架構(gòu)方案涉及用戶訪問(wèn)使用純靜態(tài)頁(yè)面HTML編寫的Web服務(wù)器,以及JSP和PHP腳本混合腳本語(yǔ)言和HTML代碼。本文內(nèi)承擔(dān)的配置是一個(gè)典型的,其中Web服務(wù)器軟件,如Apache,后綴與純粹的HTML,JSP和PHP等之

8、間的區(qū)別分別是.html,.jsp和.php。HTML代碼是直接返回到最終用戶請(qǐng)求的網(wǎng)絡(luò)瀏覽器,在JSP和PHP頁(yè)面分別由Tomcat的腳本引擎和PHP運(yùn)行時(shí)引擎提供純HTML轉(zhuǎn)發(fā)給最終在遠(yuǎn)程系統(tǒng)的用戶進(jìn)行解析。JSP和PHP之間的共同點(diǎn)是,這些執(zhí)行良好的實(shí)現(xiàn)有一個(gè)動(dòng)態(tài)編譯和緩存的字節(jié)碼。例如,Java運(yùn)行時(shí)使用Tomcat的腳本引擎,當(dāng)實(shí)時(shí)(JIT)編譯器功能來(lái)創(chuàng)建有效的本地緩存的運(yùn)行時(shí)代碼時(shí)我們執(zhí)行越好。同樣,我們使用了Zend的PHP運(yùn)行時(shí)當(dāng)可替代的PHP緩存(APC)啟用,則執(zhí)行明顯好,從共享內(nèi)存中APC存儲(chǔ)PHP字節(jié)碼,以便將來(lái)重用腳本源代碼。 表1 示例PHP和JSP腳本與生成的H

9、TML代碼PHP ScriptJSP ScriptR esulting HTML Code The date is The date is The date isTue, 1 Jan 0812:00:00 3語(yǔ)言運(yùn)行時(shí)性能微標(biāo)桿為了了解PHP語(yǔ)言運(yùn)行時(shí)水平在性能特點(diǎn)上的不同,我們比較了用微型基準(zhǔn)測(cè)試一下引擎:-PHP的4.4.7-PHP的5.2.3-Java 5與實(shí)時(shí)(JIT)編譯(IBM的J9虛擬機(jī)1.5.0 Build 2.3)-Java 5 不只是實(shí)時(shí)(JIT)編譯(同上)PHP語(yǔ)言框架允許開(kāi)發(fā)人員擴(kuò)展這些用C語(yǔ)言編寫的功能,這些功能被稱為“擴(kuò)展”,稱為庫(kù)函數(shù)的語(yǔ)言,然后提供給PHP腳本

10、內(nèi)使用。PHP運(yùn)行時(shí)提供了多種擴(kuò)展的字符串操作,文件處理,網(wǎng)絡(luò)等等。由于我們的首要目標(biāo)是了解PHP運(yùn)行時(shí)本身的性能,我們實(shí)施的實(shí)驗(yàn)沒(méi)有使用擴(kuò)展。我們制定了以下微基準(zhǔn):-以100個(gè)整數(shù)進(jìn)行快速排序的基準(zhǔn)-一個(gè)Levenshtein基準(zhǔn)檢測(cè)兩行56個(gè)字符的字符串的相似性-一個(gè)斐波納契計(jì)算基準(zhǔn),在一個(gè)任意兩個(gè)初始值斐波納契數(shù)列第15的值。這些PHP的基準(zhǔn)完全用PHP原始語(yǔ)言實(shí)現(xiàn)和避免了PHP擴(kuò)展的使用。Java的版本也側(cè)重于利用原始的語(yǔ)言而不是標(biāo)準(zhǔn)類的語(yǔ)言。我們比較了每個(gè)引擎執(zhí)行每個(gè)測(cè)試10000次的總運(yùn)行時(shí)間。每個(gè)測(cè)試前我們也執(zhí)行作為熱身的額外10000次測(cè)量基準(zhǔn)。這可以防止在Java影響得分的測(cè)

11、試中即時(shí)編譯。我們?cè)?.40GB的RAM內(nèi)存,4CPU的Intel奔騰與Linux2.6.17內(nèi)核上運(yùn)行實(shí)驗(yàn)。此測(cè)試演示測(cè)量之間的腳本語(yǔ)言和實(shí)現(xiàn)的巨大性能差異。圖1中的實(shí)驗(yàn)結(jié)果表明,“JIT編譯的Java 5”性能最好,在所有測(cè)量案件中“沒(méi)有JIT編譯的Java 5”,“PHP的5.2.3”,“PHP的4.4.7”次之。Java 5基于有效地生成本地代碼使用,結(jié)合JIT演示了近三個(gè)數(shù)量級(jí)更好性能的訂單。顯而易見(jiàn)的是,PHP的5.2.3有兩倍至三倍的性能改進(jìn)超過(guò)實(shí)際測(cè)量計(jì)算的PHP的4.4.7。其次,以PHP與Java類的方法相比確定擴(kuò)展性能的影響,我們開(kāi)發(fā)和測(cè)試三種額外的微基準(zhǔn):常規(guī)的表達(dá)式匹

12、配,MD5編碼和Levenshtein比較。對(duì)于常規(guī)表達(dá)式匹配,Perl兼容常規(guī)表達(dá)式擴(kuò)展(通過(guò)preg_match()函數(shù))使用PHP和在Java中使用java.util.regex包。對(duì)于MD5編碼,MD5的擴(kuò)展也在PHP中使用和在Java中使用java.security.MessageDigest。這個(gè)實(shí)驗(yàn)沒(méi)有比較完全相同的邏輯,而是表明PHP擴(kuò)展的使用與Java即時(shí)編譯競(jìng)爭(zhēng),如圖2所示。盡管實(shí)驗(yàn)結(jié)果顯示純腳本的三個(gè)數(shù)量級(jí)在Java和PHP上實(shí)現(xiàn)更少的性能差異訂單,但是PHP的擴(kuò)展使用(用C語(yǔ)言編寫)和編譯Java類庫(kù)的變化表現(xiàn)出很大的不同。在極端情況下,正常的表達(dá)式測(cè)試顯示Java和P

13、HP之間最高的性能差異大約為5分鐘,在另一方面,Java和PHP在MD5測(cè)試結(jié)果中幾乎相等。因此,一個(gè)例如PHP等腳本語(yǔ)言解釋的固有性能風(fēng)險(xiǎn)是可以利用高效率的庫(kù)函數(shù)來(lái)克服的,如使用C語(yǔ)言編寫的PHP擴(kuò)展。4議論 其中一個(gè)審查性能基準(zhǔn)測(cè)試結(jié)果時(shí),它出現(xiàn)在腦海的第一個(gè)問(wèn)題是,“為什么JSP往往在高負(fù)荷下有更好的表現(xiàn),然后PHP?”一個(gè)主要的原因是Java準(zhǔn)時(shí)(JIT)編譯器。雖然JIT一直與PHP APC相比,APC是僅僅從而降低了對(duì)源代碼的重新演繹的需要,而JIT實(shí)現(xiàn)高度優(yōu)化的本地機(jī)器指令的執(zhí)行字節(jié)碼緩存。這反映在圖14中,其中的Java有JIT示出了在運(yùn)行時(shí)引擎花費(fèi)最少的時(shí)間。另一個(gè)因素是,J

14、SP通過(guò)線程模型來(lái)實(shí)現(xiàn)并行化,而在本試驗(yàn)所采用的常用的Apache工人/ mod_php的方法,通過(guò)使用多個(gè)進(jìn)程來(lái)實(shí)現(xiàn)并行化。這樣高的CPU負(fù)載下,人們會(huì)期望與JSP實(shí)現(xiàn)使用的線程模型少調(diào)度和上下文切換的開(kāi)銷。 另一個(gè)看似反常的一點(diǎn)是,使用PHP與Lighttpd的在支持方案優(yōu)于JSP在高負(fù)載下,這意味著PHP可以處理比JSP I / O更好。原來(lái),人們所期望的節(jié)目的不同性能特性,例如這是寫在低C級(jí)PHP運(yùn)行時(shí),并且基于Java JSP環(huán)境的。在Web服務(wù)器體系結(jié)構(gòu)的差異也發(fā)揮的一個(gè)因素,在這里似乎最好Apache的多進(jìn)程“prefork的”做法,Lighttpd的使用異步事件處理的方法。使用

15、過(guò)程中的語(yǔ)言處理時(shí)相當(dāng)輕巧,如與mod_php的情況下出現(xiàn)的案例。同樣的,外部語(yǔ)言處理與Tomcat類似是避免重量級(jí)JVM復(fù)制每個(gè)進(jìn)程取得成功。通過(guò)FCGI外部語(yǔ)言處理的辦法也出現(xiàn)與Lighttpd的非常成功。內(nèi)部mod_php的方法的優(yōu)點(diǎn)在于從硬盤讀取數(shù)據(jù)時(shí)可立即到Apache,因?yàn)镻HP引擎在同一個(gè)地址空間作為Apache守護(hù)進(jìn)程運(yùn)行。但是,JVM使用用JSP和PHP通過(guò)FCGI訪問(wèn)運(yùn)行在一個(gè)單獨(dú)的進(jìn)程,從而招致域套接字通信開(kāi)銷從工藝上下文切換和傳輸協(xié)調(diào)文件數(shù)據(jù)從一個(gè)進(jìn)程到另一個(gè),以及潛在的低效率。5相關(guān)工作 Titchkosky和同事建立了服務(wù)于動(dòng)態(tài)網(wǎng)頁(yè)內(nèi)容可以通過(guò)8倍的吞吐量減少與靜態(tài)

16、Web內(nèi)容相比,為廣大團(tuán)隊(duì)的鼓勵(lì),以確定方法,減少使用腳本語(yǔ)言的動(dòng)態(tài)Web內(nèi)容的負(fù)面的性能影響。拉瑪納和普拉巴卡爾分析PHP和匯編語(yǔ)言如C之間的性能差異,指出PHP的相對(duì)性能缺點(diǎn),這與我們對(duì)純腳本執(zhí)行的基準(zhǔn)測(cè)試對(duì)比對(duì)應(yīng)。用C語(yǔ)言實(shí)現(xiàn)的標(biāo)準(zhǔn)類庫(kù)或PHP擴(kuò)展腳本。我們的標(biāo)桿的好處是,我們發(fā)現(xiàn)使用C語(yǔ)言PHP擴(kuò)展的計(jì)算密集型功能,使PHP腳本使用Java進(jìn)行同等。Cecchet和他的同事分析的基礎(chǔ)上的技術(shù),如Apache,PHP,Tomcat的,MySQL的,和Jonas3,17,這有助于指導(dǎo)我們的方法不同的中間件架構(gòu)。Warner和Worley描述諸如PHP,而不是僅僅針對(duì)JSP現(xiàn)實(shí)世界與SPEC

17、web200518利用基準(zhǔn)技術(shù)的重要性。因?yàn)槲覀儧](méi)有一個(gè)行業(yè)標(biāo)準(zhǔn)Web服務(wù)器基準(zhǔn)測(cè)試,它提供的性能PHP和JSP的Web服務(wù)器動(dòng)態(tài)腳本語(yǔ)言進(jìn)行了詳細(xì)的比較可以看出,我們的數(shù)據(jù)已經(jīng)到這種推理貢獻(xiàn),因?yàn)槲覀兪莿?dòng)機(jī)寫文章。外文原文 Performance Comparison of PHP and JSP as Server-Side Scripting LanguagesMaterialSource: Notesin Computer Science Author: Scott Trent; Michiaki Tatsubori; Toyotaro Suzumura; Akihiko Tozawa

18、 and Tamiya OnoderaAbstract. The dynamic scripting language PHP has become enormously popular for implementing lightweight web applications, and is widely used as a server-side scripting language for web servers. To contrast the performance of PHP and JSP for this purpose, we used the SPECweb2005 be

19、nchmark, which provides three application scenarios implemented in both PHP and JSP. This paper describes and contrasts the results of SPECweb2005 performance benchmark testing performed on different configurations of PHP and JSP using the popular web servers Apache and Lighttpd. Despite the executi

20、on overhead of interpretation in PHP engines observed in micro benchmarks, the experimental result of SPECweb2005 benchmark yields valuable performance data for web server implementers. The efficiency of scripting language runtimes still matters for the end-to-end performance. However, once carefull

21、y architected and tuned, the language runtime is less of a bottleneck than the web server performance itself.Keywords: PHP, JSP, SPECweb, Benchmarking, Web Server1 IntroductionThe dynamic scripting language PHP(PHP Hypertext Preprocessor) has become enormously popular for implementing lightweight we

22、b applications,and is widely used to access databases and other middleware.Apache module popularity surveys performed by Security Space in October 2007 indicate that 37% of Apache servers have PHP support enabled ,making it the most popular Apache module by 10 percentage points.Businesses are quickl

23、y realizing the powerful combination of a service oriented architecture environment with dynamic scripting languages like PHP .However,we believe that there are still critical performance issues involving PHP which remain to be investigated.This paper focuses on the use of dynamic scripting language

24、s to implement web server front-end interfaces. This corresponds with the way that the industry standard web server performance benchmark SPECweb2005 utilizes PHP and JSP ( JavaServer Pages).In this case, scripts are used for the implementation of dynamic page generation, rather than the realization

25、 of complex business logic. This contrasts with the traditional uses of complex JSP-based business logic implementation.While there are numerous studies on dynamic web content, this paper complements these studies with detailed analysis focusing on PHP. For example, following the performance study o

26、n CGI (Common Gateway Interface) based web servers for dynamic content by Yeager & McGrath back in 1995, researchers and practitioners have been examining the performance of more recent dynamic Webcontent generation technologies. These works, however, handle application scenarios where servlet front

27、-ends implement relatively complex business logic. Although Warner and Worley discuss the importance of also using PHP with SPECweb2005, to the best of the authors knowledge, this paper is the first to publish a detailed analysis of SPECweb2005 experimental results using both PHP and JSP. The detail

28、ed analysis of PHP and JSP performance based on SPECweb2005 offered by this paper enables designers and implementers of web servers to understand the relative performance and through put of different versions and configurations of PHP and JSP.2 Multi-tier Web Server Architecture: Lightweight Front-E

29、nd Using PHP/JSP Developers typically use PHP to implement a front-end interface to dynamic Web content generators, which are combined with web server software and back-end servers to provide dynamic content. The web server directly handles requests for static content and forwards requests for dynam

30、ic content to the dynamic content generator. The dynamic content generator, supported by back-end servers, executes code which realizes the business logic of a web site and stores dynamic state. Back-end servers may be implemented as a straight-forward database, or may be more complex servers handli

31、ng the business logic of the web site. The front-end implementation may vary from heavy-weight business logic handlers to lightweight clients composing content received from back-end servers. This paper focuses on multi-tier web site development scenarios utilizing such lightweight front-ends, suppo

32、rted by one or more layers of heavy-weight back-ends. This assumption is reasonable when considering Service-Oriented environments where PHP scripts are used to implement a mash-up of services provided elsewhere, in addition to the case of simple web sites such as bulletin boards where PHP scripts a

33、re just a wrapper to a database. Within the scenarios described in this paper, the dynamic content generator provides client implementation in addition to page composition. It connects to the back-end server through a network using either standard protocols such as HTTP or application/middleware-spe

34、cific protocols.JSP technology can be considered an alternative to PHP in implementing such front-ends. While it is part of the Java Servlet framework, developers typically use JSP to implement lightweight front-ends. Both PHP and JSP allow developers to write HTML embedded code. In fact, although t

35、here are language inherent differences between PHP and Java, the use of PHP scripts and JSP files can be very similar. The objective of the experiments detailed in this paper is to measure the performance of lightweight front-end dynamic content generation written in PHP and JSP with popular web ser

36、vers such as Apache and Lighttpd. This web server architecture scenario involves users who access a web server with pages written in plain static HTML, as well as JSP and PHP scripts which mix scripting language with HTML code. The configuration assumed within the paper is a typical one, where web s

37、erver software, such as Apache, distinguishes between pure HTML, JSP, and PHP respectively with suffixes such as .html, .jsp, and .php. HTML code is directly returned to the requesting end-users web browser, where JSP and PHP pages are respectively parsed by the Tomcat script engine and the PHP runt

38、ime engine which both provide pure HTML which is forwarded to the end-user on a remote system. A common point between JSP and PHP is that implementations which perform well have a dynamically compiled and cached byte code. For example, the Java runtime used by the Tomcat script engine which we used

39、performs much better when the Just-in-Time (JIT) compiler is enabled to create efficient cached native runtime code. Similarly, the Zend PHP runtime we used also performs significantly better when the Alternative PHP Cache (APC) is enabled, in which APC stores PHP byte codes compiled from the script

40、 source code in shared memory for future reuse. Table 1. Sample PHP and JSP scripts with resulting HTML codePHP ScriptJSP ScriptR esulting HTML Code The date is The date is The date isTue, 1 Jan 0812:00:00 3 Language Runtime Performance Micro BenchmarkingTo understand the difference in performance c

41、haracteristics between PHP and Java at the language runtime level,we compared the following engines using a series of micro benchmark tests:- PHP 4.4.7 - PHP 5.2.3 - Java 5 with Just-In-Time (JIT) compilation (IBM J9 VM 1.5.0 Build 2.3) - Java 5 without Just-In-Time (JIT) compilation (same as above)

42、The PHP language framework allows developers to extend the language with library functions written in C. These functions, which are known as extensions, are then available to be used within PHP scripts. The PHP runtime provides a variety of extensions for string manipulation, file handling, networki

43、ng, and so forth. Since our first goal was to understand the performance of the PHP runtime itself, we conducted our experiments without the use of extensions. We developed the following micro benchmarks: - A quick sort benchmark which sorts 100 integers, - A Levenshtein benchmark which measures the

44、 similarity between two strings of 56 characters, -A Fibonacci benchmark which calculates the 15th value in a Fibonacci series with two arbitrary starting values.These PHP benchmarks were implemented entirely with PHP language primitives and avoided the use of PHP extensions. The Java versions also

45、focused on using language primitives rather than standard classes. We compared the total run time of executing each test 10,000 times with each engine. We also executed each benchmark an additional 10,000 times as a warm-up, before the measured test. This prevents Java just-in-time compilation overh

46、ead from impacting the score in the Java tests. We ran the experiment on an Intel Pentium 4 CPU at 3.40 GHz with 3GB RAM Memory, with the Linux 2.6.17 kernel. This test demonstrates large performance differences between each of themeasured scripting languages and implementations. The experimental re

47、sults in Figure 1 indicate that “Java 5 with JIT compilation” performs the best, followed “Java 5 without JIT compilation”, “PHP 5.2.3”, and “PHP 4.4.7” in all measured cases. Java 5 with JIT demonstrated nearly three orders of magnitude better performance due to the use of efficiently generated nat

48、ive code. It is also obvious that PHP 5.2.3 has a two to three times performance improvement over PHP 4.4.7 with the measured computations. Secondly to determine the performance effect of PHP extensions compared with Java class methods, we developed and tested three additional micro benchmarks: regu

49、lar expression matching, MD5 encoding, and Levenshtein comparison. For regular expression matching, the Perl Compatible Regular Expression extension (through the preg_match() function) was used in PHP, and the java. util.regex package was used in Java. For MD5 encoding, the MD5 extension was used in

50、 PHP and java.security. MessageDigest was used in Java. This experiment does not compare exactly the same logic, but rather demonstrates that the use of PHP extensions is competitive with Java using just-in-time compilation, as seen in Figure 2.Although the pure script experiment showed three orders

51、 of magnitude difference between the performance of various implementations of Java and PHP, the use of PHP extensions (written in C) and compiled Java class libraries show much less variation. In the extreme, the regular expression test showed a maximum performance difference of about five times be

52、tween Java and PHP, on the other end, the MD5 test results were nearly equivalent between Java and PHP. Thus a inherent performance risk of interpreted scripted languages such as PHP can be overcome with the use of efficient library functions such as PHP extensions written in C.4 DiscussionOne of th

53、e first questions which comes to mind when reviewing the performance benchmark results is, “Why does JSP tend to perform better then PHP under high loads?” One major reason is the Java Just in Time (JIT) Compiler. Although JIT has been compared with PHP APC, APC is merely a bytecode cache which redu

54、ces the need for re-interpretation of source code, whereas JIT enables the execution of highly optimized local machine instructions. This is reflected in Figure 14, where Java with JIT shows the least time spent in the runtime engine. Another factor is that JSP realizes parallelization through the t

55、hreading model, whereas the commonly used Apache worker/mod_php approach adopted in this testing realizes parallelization through the use of multiple processes. Thus under high CPU loads, one would expect less scheduling and context switch overhead with the threading model used with the JSP implemen

56、tation. Another seemingly anomalous point is that PHP used with Lighttpd outperformed JSP under high loads in the Support scenario, implying that PHP can handle I/O better than JSP. Initially, one would expect different performance characteristics of a program such as the PHP runtime which is writte

57、n in low level C, and that of the Java based JSP environment. The difference in web server architectures also plays a factor, where the asynchronous event-handling approach used in Lighttpd appears preferable to Apaches multi-process “prefork” approach. The use of in-process language processing appears successful when reasonably lightweight, as is the case with mod_php. Likewise, external language processing as with Tomcat seems to be successful by avoiding replication of a heavy-weight JVM for each process. The external language process

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論