1
2
3
4
5
6
Performance Comparison of PHP and JSP as Server-Side Scripting Languages
MaterialSource:Notesin Computer Science
Author: Scott Trent;Michiaki Tatsubori; Toyotaro Suzumura;Akihiko Tozawa and TamiyaOnodera
1 Introduction
The dynamic scripting language PHP(PHP Hypertext Preprocessor) has becomeenormously popular for implementing lightweight web applications,and is widely used toaccess databases and other middleware.Apache module popularity surveys performed bySecurity Space in October 2007 indicate that 37%of Apache servers have PHP supportenabled,making it the most popular Apache module by 10 percentage points.Businessesare quickly realizing the powerful combination of a service oriented architectureenvironment with dynamic scripting languages like PHP.However,we believe that thereare still critical performance issues involving PHP which remain to be investigated.
This paper focuses on the use of dynamic scripting languages to implement webserver front-end interfaces.This corresponds with the way that the industry standard webserver performance benchmark SPECweb2005 utilizes PHP and JSP ( JavaServerPages).In this case, scripts are used for the implementation of dynamic page generation,rather than the realization of complex business logic.This contrasts with the traditionaluses of complex JSP-based business logic implementation.While there are numerousstudies on dynamic web content, this paper complements these studies with detailedanalysis focusing on PHP. For example, following the performance study on CGI(Common Gateway Interface) based web servers for dynamic content by Yeager&McGrath back in 1995, researchers and practitioners have been examining theperformance of more recent dynamic Webcontent generation technologies.These works,however, handle application scenarios where servlet front-ends implement relativelycomplexbusiness logic.
Although Warner and Worley discuss the importance of also using PHP withSPECweb2005, to the best of the author’s knowledge, this paper is the first to publish adetailed analysis of SPECweb2005 experimental results using both PHP and JSP. Thedetailed analysis of PHP and JSP performance based on SPECweb2005 offered by thispaper enables designers and implementers of web servers to understand the relativeperformance and through put of different versions and configurations of PHP and JSP.
7
2 Multi-tier Web Server Architecture:Lightweight Front-EndUsing PHP/JSP
Developers typically use PHP to implement a front-end interface to dynamic Webcontent generators,which are combined with web server software and back-end serversto provide dynamic content.The web server directly handles requests for static contentand forwards requests for dynamic content to the dynamic content generator. Thedynamic content generator, supported by back-end servers, executes code which realizesthe business logic of a web site and stores dynamic state. Back-end servers may beimplemented as a straight-forward database, or may be more complex servers handlingthe business logic of the web site. The front-end implementation may vary fromheavy-weight business logic handlers to lightweight clients composing content receivedfrom back-end servers.
This paper focuses on multi-tier web site development scenarios utilizing suchlightweight front-ends, supported by one or more layers o f heavy-weight back-ends.Thisassumption is reasonable when considering Service-Oriented environments where PHPscripts are used to implement a "mash-up"of services provided elsewhere, in addition tothe case of simple web sites such as bulletin boards where PHP scripts are just a wrapperto a database. Within the scenarios described in this paper, the dynamic contentgenerator provides client implementation in addition to page composition. It connects tothe back-end server through a network using either standard protocols such as HTTP orapp lication/middleware-spec ific proto co ls.
JSP technology can be considered an alternative to PHP in implementing suchfront-ends.While it is part of the Java Servlet framework,developers typically use JSP toimplement lightweight front-ends.Both PHP and JSP allow developers to write HTMLembedded code. In fact, although there are language inherent differences between PHPand Java, the use ofPHP scripts and JSP files can be very similar.
The objective of the experiments detailed in this paper is to measure theperformance of lightweight front-end dynamic content generation written in PHP and JSPwith popular web servers such as Apache and Lighttpd. This web server architecturescenario 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. Theconfiguration assumed within the paper is a typical one,where web server software, suchas Apache,distinguishes between pure HTML, JSP,and PHP respectively with suffixes
8
such as .html, .jsp,and.php.HTML code is directly returned to the requesting end-user’sweb browser,where JSP and PHP pages are respectively parsed by the Tomcat scriptengine and the PHP runtime engine which both provide pure HTML which is forwardedto the end-user on a remote system.A common point between JSP and PHP is thatimplementations 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 performsmuch better when the Just-in-Time (JIT) compiler is enabled to create efficient cachednative runtime code. Similarly, the Zend PHP runtime we used also performssignificantly better when the Alternative PHP Cache (APC) is enabled, in which APCstores PHP byte codes compiled from the script source code in shared memory for futurere us e.
3 Language Runtime Performance Micro Benchmarking
To understand the difference in performance characteristics between PHP and Javaat the language runtime levelwe compared the following engines using a series of microbenchmark te sts:
-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)
The PHP language framework allows developers to extend the language with libraryfunctions written in C. These functions,which are known as "extensions", are thenavailable to be used within PHP scripts. The PHP runtime provides a variety ofextensions for string manipulation, file handling,networking,and so forth.S ince our firstgoal was to understand the performance of the PHP runtime itself,we conducted ourexperiments without the use of extensions.We developed the following microbenc hmarks:
-A quick sort benchmark which sorts 100 integers,
-A Levenshtein benchmark which measures the similarity between two strings of 56charac ter s,
-AFibonacci benchmark which calculates the 15th value in a Fibonacci series withtwo arb itrary starting values.
These PHP benchmarks were implemented entirely with PHP language primitivesand avoided the use of PHP extensions. The Java versions also focused on usinglanguage primitives rather than standard classes.We compared the total run time of
9
Krypt这两天发布了ION平台9月份优惠信息,提供一款特选套餐年付120美元(原价$162/年),开设在洛杉矶或者圣何塞机房,支持Windows或者Linux操作系统。ion.kryptcloud.com是Krypt机房上线的云主机平台,主要提供基于KVM架构云主机产品,相对于KT主站云服务器要便宜很多,产品可选洛杉矶、圣何塞或者新加坡等地机房。洛杉矶机房CPU:2 cores内存:2GB硬盘:...
近期联通CUVIP的线路(AS4837线路)非常火热,妮妮云也推出了这类线路的套餐以及优惠,目前到国内优质线路排行大致如下:电信CN2 GIA>联通AS9929>联通AS4837>电信CN2 GT>普通线路,AS4837线路比起前两的优势就是带宽比较大,相对便宜一些,所以大家才能看到这个线路的带宽都非常高。妮妮云互联目前云服务器开放抽奖活动,每天开通前10台享3折优惠,另外...
? ? ? ?创梦网络怎么样,创梦网络公司位于四川省达州市,属于四川本地企业,资质齐全,IDC/ISP均有,从创梦网络这边租的服务器均可以****,属于一手资源,高防机柜、大带宽、高防IP业务,另外创梦网络近期还会上线四川联通大带宽,四川联通高防IP,一手整CIP段,四川电信,联通高防机柜,CN2专线相关业务。成都优化线路,机柜租用、服务器云服务器租用,适合建站做游戏,不须要在套CDN,全国访问快...