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
racknerd怎么样?racknerd商家最近促销三款美国便宜vps,最低只需要9.49美元,可以选择美国圣何塞、西雅图、纽约和芝加哥机房。RackNerd是一家成立于2019年的美国高性价比服务器商家,主要从事美国和荷兰数据中心的便宜vps、独立服务器销售!支持中文工单、支持支付宝和微信以及PayPal付款购买!点击直达:racknerd官方网站INTEL系列可选机房:加利福尼亚州圣何塞、芝加...
亚洲云Asiayun怎么样?亚洲云成立于2021年,隶属于上海玥悠悠云计算有限公司(Yyyisp),是一家新国人IDC商家,且正规持证IDC/ISP/CDN,商家主要提供数据中心基础服务、互联网业务解决方案,及专属服务器租用、云服务器、云虚拟主机、专属服务器托管、带宽租用等产品和服务。Asiayun提供源自大陆、香港、韩国和美国等地骨干级机房优质资源,包括BGP国际多线网络,CN2点对点直连带宽以...
对于如今的云服务商的竞争着实很激烈,我们可以看到国内国外服务商的各种内卷,使得我们很多个人服务商压力还是比较大的。我们看到这几年的服务商变动还是比较大的,很多新服务商坚持不超过三个月,有的是多个品牌同步进行然后分别的跑路赚一波走人。对于我们用户来说,便宜的服务商固然可以试试,但是如果是不确定的,建议月付或者主力业务尽量的还是注意备份。HostYun 最近几个月还是比较活跃的,在前面也有多次介绍到商...