性能PHP和JSP作为服务器脚本语言的性能比较-外文翻译

jsp服务器  时间:2021-04-29  阅读:()

毕

课题名称

系 部

专 业

班 级

学 号

姓 名

指导教师

2017年4月 14 日

Performance Comparison of PHP and JSP as Server-Side

Scripting Languages

MaterialSource:Notesin Computer Science

Author:Sc ott Trent;Michiaki Tatsubori;Toyotaro Suzumura;Akihiko Tozawa and Tamiya Onodera

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.Businesses arequickly realizing the powerful combinatio n of a service oriented architecture environmentwith dynamic scripting languages like PHP.However,we believe that there are still criticalperformance issues involving PHP which remain to be investigated.

This paper focuses on the use of dynamic scripting languages to implement web serverfront-end interfaces. This corresponds with the way that the industry standard web serverperformance benchmark SPECweb2005 utilizes PHP and JSP(JavaServer Pages).In this case,scripts are used for the implementation of dynamic page generation, rather than therealization of complex business logic. This contrasts with the traditional uses of complexJSP-based business logic implementation.While there are numerous studies on dynamic webcontent, this paper complements these studies with detailed analysis focusing on PHP.Forexample, following the performance study on CGI (Common Gateway Interface)based webservers for dynamic content by Yeager &McGrath back in 1995, researchers andpractitioners have been examining the performance of more recent dynamic Webcontentgeneration technologies. These works, however, handle application scenario s where servletfront-ends implement relatively complex business 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 this paperenables designers and implementers of web servers to understand the relative performanceand through put of different versions and configurations ofPHP and JSP.

1

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 servers toprovide dynamic content. The web server directly handles requests for static content andforwards requests for dynamic content to the dynamic content generator. The dynamiccontent generator, supported by back-end servers, executes code which realizes the businesslogic of a web site and stores dynamic state. Back-end servers may be implemented as astraight-forward database,or may be more complex servers handling the business logic of theweb site.The front-end implementation may vary from heavy-weight business logic handlersto lightweight clients composing content received from back-end servers.

This paper focuses on multi-tier web site development scenarios utilizing suchlightweight front-ends, supported by one or more layers of 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 to thecase of simple web sites such as bulletin boards where PHP scripts are just a wrapper to adatabase. Within the scenarios described in this paper, the dynamic content generatorprovides client implementation in addition to page composition. It connects to the back-endserver through a network using either standard protocols such as HTTP orapp licatio n/middleware-spec ific p rotoco 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 PHP andJava, 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 oflightweight front-end dynamic content generation written in PHP and JSP with popular webservers such as Apache and Lighttpd.This web server architecture scenario involves userswho access a web server with pages written in plain static HTML, as well as JSP and PHPscripts which mix scripting language with HTML code.The configuration assumed withinthe paper is a typical one,where web server software, such as Apache,distinguishes betweenpure HTML, JSP, and PHP respectively with suffixes such as .html, .jsp, and .php.HTMLcode is directly returned to the requesting end-user’s web browser,where JSP and PHP pages

2

are respectively parsed by the Tomcat script engine and the PHP runtime engine which bothprovide pure HTML which is forwarded to the end-user on a remote system.A common pointbetween JSP and PHP is that implementations which perform well have a dynamicallycompiled and cached byte code. For example, the Java runtime used by the Tomcat scriptengine which we used performs much better when the Just-in-Time(JIT)compiler is enabledto create efficient cached native runtime code. Similarly, the Zend PHP runtime we usedalso performs significantly better when the Alternative PHP Cache (APC) is enabled, inwhich APC stores PHP byte codes compiled from the script source code in shared memoryfor future reuse.

3 Language Runtime Performance Micro Benchmarking

To understand the difference in performance characteristics between PHP and Java at thelanguage runtime level we compared the following engines using a series of microb enc hmark te st s:

-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)comp ilation(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 then availableto be used within PHP scripts.The PHP runtime provides a variety of extensions for stringmanipulation, file handling,networking,and so forth. Since our first goal was to understandthe performance of the PHP runtime itself,we conducted our experiments without the use ofextensions.We developed the fo llowing micro benchmarks:

-A quick sort benchmark which sorts 100 integers,

-A Levenshtein benchmark which measures the similarity between two strings of 56characte rs,

-AFibonaccibenchmark which calculates the 15th value in a Fibonacci series withtwo arb itrary starting values.

These PHP benchmarks were implemented entirely with PHP language primitives andavoided the use of PHP extensions. The Java versions also focused on using languageprimitives rather than standard classe s.We compared the total run time o f executing each test10,000 times with each engine.We also executed each benchmark an additional 10,000 timesas a warm-up,before the measured test.This prevents Java just-in-time compilation overheadfrom impacting the score in the Java tests.We ran the experiment on an Intel Pentium 4 CPU

3

at 3.40 GHz with 3 GB RAM Memory,with the Linux 2.6.17 kernel.

This test demonstrates large performance differences between each of themeasuredscripting languages and implementations. The experimental results 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 nearlythree orders of magnitude better performance due to the use of efficiently generated nativecode. It is also obvious that PHP 5.2.3 has a two to three times performance impro vementover PHP 4.4.7 with the measured computations. Secondly to determine the performanceeffect of PHP extensions compared with Java class methods,we developed and tested threeadditional micro benchmarks: regular expression matching,MD5 encoding,and Levenshteincomparison. For regular expression matching, the Perl Compatible Regular Expressionextension(through the preg_match() function)was used in PHP, and the java. util.regexpackage was used in Java. For MD5 encoding, the MD5 extension was used in PHP andjava.security. MessageDigest was used in Java.This experiment does not compare exactlythe same logic,but rather demonstrates that the use of PHP extensions is competitive withJava using just-in-time compilation,as seen in Figure 2.

Although the pure script experiment showed three orders of magnitude differencebetween the performance of various implementations of Java and PHP, the use of PHPextensions (written in C) and compiled Java class libraries show much less variation. In theextreme, the regular expression test showed a maximum performance difference of about fivetimes between Java and PHP,on the other end, the MD5 test results were nearly equivalentbetween Java and PHP.Thus a inherent performance risk of interpreted scripted languagessuch as PHP can be overcome with the use of efficient library functions such as PHPextensions written in C.

4

PHP和JSP作为服务器脚本语言的性能比较

资料来源:计算机科学讲义

作者Scott TrentM ichiaki TatsuboriToyotaro S uzumuraAkihiko To zawa和TamiyaOnodera

1简介

动态脚本语言P HP P HP超文本预处理器已经成为非常流行的轻量级Web执行应用程序并广泛用于访问数据库和其他中间件。 2007年10月流行的Apache模块安全空间进行的调查表明 37%的Ap ac he服务器支持P HP功能 以10个百分点使它成为最流行的Ap ac he模块。企业正迅速实现与动态脚本语言如PHP的面向服务的体系结构环境的强大组合。然而我们相信仍然有重要的性能问题涉及到P HP它仍有待于被调查。

本文重点介绍了动态脚本语言的使用来实现Web服务器的前端接口。与此对应的方式该行业标准的Web服务器性能的基准S PECweb2005利用PHP和JS PJavaS erver页面。在这种情况下脚本是用于执行动态页面生成而不是复杂的业务逻辑的实现。与此相反的传统用途是基于JSP的复杂的业务逻辑实现。虽然有许多动态网页内容的研究本文补充了这些研究的详细分析重点在于P HP中。例如下面就C GI 通用网关接口基于Web服务器的动态内容由耶格尔麦格拉思可追溯到1995年的性能研究研究人员和从业者一直在研究最近的动态的WebC onte nt技术性能。这些作品然而处理应用程序方案在servlet前端实现相对复杂的业务逻辑。

虽然华纳和沃利也使用P HP与S P EC web 2005,以作者所知的重要性本文是首次发布了使用P HP和J S P的S P EC web 2005实验结果的详细分析。P HP和J S P的性能的详细分析是基于本文件所提供的S PECweb2005使设计者和实施者了解Web服务器的相对性能并通过把不同版本的P HP和J S P进行配置。

2多层We b服务器架构使用PHP/JSP的轻量级前端

开发人员通常使用P HP来实现一个生成动态Web内容的前端界面这与Web服务器软件和后端服务器相结合提供动态内容。该网站的服务器直接处理静态内容并转发请求动态内容生成动态内容。后端服务器支持动态内容生成执行代码来实现一个网站和商店的动态状态的业务逻辑。后端服务器可以作为一个直接的数据库来实现或者可能更复杂的服务器处理该网站的业务逻辑。前端的执行可能有所不同于重量级的业务逻

5

辑程序来处理从后端服务器接收轻量级客户端的内容。

本文重点介绍多层Web站点开发利用这种由一个或多个重量级后端层支持轻量级的前端。当考虑到面向服务的环境中P HP脚本用来实现提供其他地方的一个“混搭”的服务这种假设是合理的。除了简单的网站情况下例如公告板中P HP脚本只是一个包装到一个数据库。在本文中所描述的场景中动态内容生成器提供动态内容页组成除了客户端实现。它通过使用标准协议诸如HTTP或应用程序/中间件特定协议连接到后端服务器。

JSP技术可以被认为是对PHP在执行这些前端的一种选择。虽然它是Java Servlet的框架的一部分开发人员通常使用J S P来实现轻量级前端。 P HP和J SP允许开发人员可以编写HTML嵌入代码。事实上虽然P HP和Java之间有着固有的不同之处但P HP的脚本和J S P文件在使用上的差异可能会非常相似。

在这份文件中详细介绍了实验的目的是衡量结合诸如Apac he和Lighttpd的流行Web服务器使用P HP和J S P编写的轻量级前端动态内容生成器性能。此Web服务器架构方案涉及用户访问使用纯静态页面HTML编写的Web服务器 以及JS P和PHP脚本混合脚本语言和HTML代码。本文内承担的配置是一个典型的其中Web服务器软件如Ap ac he后缀与纯粹的H TM L JS P和PHP等之间的区别分别是.html .j sp和.php。 HTM L代码是直接返回到最终用户请求的网络浏览器在JS P和PHP页面分别由Tomcat的脚本引擎和PHP运行时引擎提供纯HTML转发给最终在远程系统的用户进行解析。 J S P和P HP之间的共同点是这些执行良好的实现有一个动态编译和缓存的字节码。例如 Ja va运行时使用To mca t的脚本引擎当实时JI T编译器功能来创建有效的本地缓存的运行时代码时我们执行越好。同样我们使用了Ze nd的P HP运行时当可替代的P HP缓存AP C启用则执行明显好从共享内存中AP C存储P HP字节码 以便将来重用脚本源代码。

3语言运行时性能微标杆

为了了解P HP语言运行时水平在性能特点上的不同我们比较了用微型基准测试一下引擎

-P HP的4.4.7

-P HP的5.2.3

-Java 5与实时JIT编译IBM的J9虚拟机1.5.0 Build 2.3

-Java 5不只是实时JIT编译同上

P HP语言框架允许开发人员扩展这些用C语言编写的功能这些功能被称为“扩展”称为库函数的语言然后提供给P HP脚本内使用。 P HP运行时提供了多种扩展的字符串操作文件处理 网络等等。

6

由于我们的首要目标是了解P HP运行时本身的性能我们实施的实验没有使用扩展。

我们制定了以下微基准

-以100个整数进行快速排序的基准

-一个Le ve ns hte in基准检测两行56个字符的字符串的相似性

-一个斐波纳契计算基准在一个任意两个初始值斐波纳契数列第15的值。

这些P HP的基准完全用P HP原始语言实现和避免了P HP扩展的使用。Ja va的版本也侧重于利用原始的语言而不是标准类的语言。我们比较了每个引擎执行每个测试10000次的总运行时间。每个测试前我们也执行作为热身的额外10000次测量基准。这可以防止在Java影响得分的测试中即时编译。我们在3.40 GB的RAM内存 4CPU的Inte l奔腾与L inux 2.6. 17内核上运行实验。

此测试演示测量之间的脚本语言和实现的巨大性能差异。 图1中的实验结果表明“JIT编译的Java 5”性能最好在所有测量案件中“没有JIT编译的Java 5” “PHP的5.2.3” “PHP的4.4.7”次之。 Java 5基于有效地生成本地代码使用结合JIT演示了近三个数量级更好性能的订单。显而易见的是 P HP的5.2.3有两倍至三倍的性能改进超过实际测量计算的P HP的4.4.7。其次 以P HP与Ja va类的方法相比确定扩展性能的影响我们开发和测试三种额外的微基准常规的表达式匹配MD5编码和Le ve ns hte in比较。对于常规表达式匹配 P er l兼容常规表达式扩展通过pre g_matc h()函数使用PHP和在Java中使用java.util.re gex包。对于MD5编码MD5的扩展也在PHP中使用和在Java中使用java.security.MessageDige st。这个实验没有比较完全相同的逻辑而是表明P HP扩展的使用与Ja va即时编译竞争如图2所示。

尽管实验结果显示纯脚本的三个数量级在J ava和P HP上实现更少的性能差异订单但是PHP的扩展使用用C语言编写和编译Ja va类库的变化表现出很大的不同。在极端情况下正常的表达式测试显示Java和P HP之间最高的性能差异大约为5分钟在另一方面 Java和PHP在MD5测试结果中几乎相等。因此一个例如PHP等脚本语言解释的固有性能风险是可以利用高效率的库函数来克服的如使用C语言编写的P HP扩展。

7

指导老师批阅手写

签名

8

ZJI(月付480元),香港阿里云专线服务器

ZJI是成立于2011年原Wordpress圈知名主机商—维翔主机,2018年9月更名为ZJI,主要提供香港、日本、美国独立服务器(自营/数据中心直营)租用及VDS、虚拟主机空间、域名注册业务。本月商家针对香港阿里云线路独立服务器提供月付立减270-400元优惠码,优惠后香港独立服务器(阿里云专线)E3或者E5 CPU,SSD硬盘,最低每月仅480元起。阿里一型CPU:Intel E5-2630L...

域名注册需要哪些条件(新手注册域名考虑的问题)

今天下午遇到一个网友聊到他昨天新注册的一个域名,今天在去使用的时候发现域名居然不见。开始怀疑他昨天是否付款扣费,以及是否有实名认证过,毕竟我们在国内域名注册平台注册域名是需要实名认证的,大概3-5天内如果不验证那是不可以使用的。但是如果注册完毕的域名找不到那也是奇怪。同时我也有怀疑他是不是忘记记错账户。毕竟我们有很多朋友在某个商家注册很多账户,有时候自己都忘记是用哪个账户的。但是我们去找账户也不办...

PIGYUN:美国联通CUVIPCUVIP限时cuvip、AS9929、GIA/韩国CN2机房限时六折

pigyun怎么样?PIGYunData成立于2019年,2021是PIGYun为用户提供稳定服务的第三年,目前商家提供香港CN2线路、韩国cn2线路、美西CUVIP-9929、GIA等线路优质VPS,基于KVM虚拟架构,商家采用魔方云平台,所有的配置都可以弹性选择,目前商家推出了七月优惠,韩国和美国所有线路都有相应的促销,六折至八折,性价比不错。点击进入:PIGYun官方网站地址PIGYUN优惠...

jsp服务器为你推荐
投标迅雷重庆重庆设置xpSinglesb支持ipad支持ipad敬请参阅报告结尾处免责声明重庆宽带测速重庆哪一种宽带网速最快360chrome360的chrome浏览器进程有点多哦???win7关闭135端口如何关闭135端口,关闭它有什么影响么?
国外免费域名网站 godaddy主机 pw域名 uk2 cpanel主机 ibox官网 阿里云浏览器 183是联通还是移动 135邮箱 卡巴斯基免费试用 服务器监测 美国独立日 web服务器是什么 全能空间 国内空间 带宽测试 alexa搜 跟踪路由 nano ddos攻击器 更多