1、 外文翻译 Performance Comparison of PHP and JSP as Server-Side Scripting Languages Material Source: IBM Tokyo Research Laboratory 16-23-14 Shimotsuruma Yamato-shi, Japan 242-8502 trent,mich,toyo,atozawa, Author:Scott Trent, Michiaki Tatsubori, Toyotaro Suzumura, Akihiko Tozawa,and Tamiya Onodera Abstrac
2、t. 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 benchmark, which provides th
3、ree 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 execution overhead of interpretat
4、ion 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 carefully architected and tuned, t
5、he language runtime is less of a bottleneck than the web server performance itself. Keywords: PHP, JSP, SPECweb, Benchmarking, Web Server. 1 Introduction The dynamic scripting language PHP (PHP Hypertext Preprocessor) has become enormously popular for implementing lightweight web applications, and i
6、s 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 11, making it the most popular Apache module by 10 percentage points. Businesses are quickly realizing the
7、 powerful combination of a service oriented architecture environment with dynamic scripting languages like PHP5. 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 languages to impleme
8、nt 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 of complex
9、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 on CGI (Comm
10、on 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 Web content generation technologies 3, 13, 15, 17. These works, however, handle application scenarios where servlet f
11、ront-ends implement relatively complex business logic. Although Warner and Worley discuss the importance of also using PHP with SPECweb2005 18, 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
12、 detailed 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 throughput of different versions and configurations of PHP and JSP. The rest of this paper is organized as follows. Se
13、ction 2 discusses multi-tier web server architecture and the lightweight front-end approach using PHP and JSP.Section 3 reports on our findings regarding PHP and JSP language runtime micro benchmark performance. Section 4 details our SPECweb2005 benchmark methodology, environment, and test configura
14、tions. Section 5 analyzes SPECweb2005 benchmark throughput results, CPU usage profiling, and related performance metrics.Section 6 discusses the importance of these results. Section 7 covers related work,followed by our conclusions in Section 8. 2 Multi-tier Web Server Architecture: Lightweight Fron
15、t-End 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 dy
16、namic 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 ha
17、ndling 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, s
18、upported 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 scri
19、pts are 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/middlewar
20、e-specific 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, alth
21、ough there 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 w
22、eb servers 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
23、 web server 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 PH
24、P runtime engine which both provide pure HTML which is forwarded to the end-user on a remote system. (A sample comparison of similar trivial JSP and PHP scripts, along with resulting HTML code can be seen in Table 1) A common point between JSP and PHP is that implementations which perform well have
25、a dynamically compiled and cached byte code. For example, the Java runtime used by the Tomcat script engine which we used 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 signifi
26、cantly better when the Alternative PHP Cache (APC) is enabled, in which APC stores PHP byte codes compiled from the script source code in shared memory for future reuse. 6 Discussion One of the first questions which comes to mind when reviewing the performance benchmark results is, “Why does JSP ten
27、d 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 reduces the need for re-interpretation of source code, whereas JIT enables the execution of highly optimized loc
28、al 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 threading model, whereas the commonly used Apache worker/mod_php approach adopted in this testing realizes pa
29、rallelization 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 implementation. Another seemingly anomalous point is that PHP used with Lighttpd outperformed JSP under high loads i
30、n 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 written in low level C, and that of the Java based JSP environment. The difference in web server architectures als
31、o 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 processi
32、ng as with Tomcat seems to be successful by avoiding replication of a heavy-weight JVM for each process. The external language processing approach via FCGI also appears highly successful with Lighttpd. The internal mod_php approach offers the advantage that data read from disk is immediately availab
33、le to Apache, since the PHP engine runs in the same address space as the Apache daemon. However, the JVM used with JSP as well as PHP accessed via FCGI runs in a separate process and thus incurs domain socket communication overhead to transmit file data from one process to another, as well as potent
34、ial inefficiencies from process context switching and coordination. 7 Related Work Titchkosky and associates established that serving dynamic web content can reduce throughput by 8 times as compared with static web content 13, providing our team with encouragement to identify methods to reduce the n
35、egative performance impact of using scripted language dynamic web content. Ramana and Prabhakar analyzed the performance differences between PHP and compiled languages such as C, pointing out the relative performance downside of PHP 10, which corresponds with our tests on pure-script implemented ben
36、chmarks vs. scripts using standard class library or PHP extensions implemented in C language. The upside of our benchmarking is that we found the use of C-language PHP extensions for computationally intensive functions to enable PHP scripts to perform comparably with Java. Cecchet and colleagues ana
37、lyze various middleware architectures based on technology such as Apache, PHP, Tomcat,MySQL, and JOnAS 3, 17, which helped guide our methodology. Warner and Worley describe the importance of using technology such as PHP rather than just JSP for real-world benchmarking with SPECweb2005 18. We have co
38、ntributed to this line of reasoning as we were motivated to write this paper since we have not seen data from an industry standard web server benchmark that provides a detailed comparison of the performance PHP and JSP as a web server dynamic scripting language. 8 Conclusion When implementing a web
39、server system which will never experience high load, or in which performance, throughput, and reliability under high load is not an issue, then the use of any of the analyzed languages or web servers will achieve similar performance results. If outstanding performance and throughput is the primary g
40、oal, then the use of JSP over PHP is advisable. However, if a 5-10% difference in throughput and performance is acceptable, then the implementer of a web system can achieve similar results using either PHP or JSP. In which case, other requirements such as developer language familiarity and programmi
41、ng efficiency, maintainability, security, reliability, middleware compatibility, etc. would be the deciding factors. It is also reassuring to developers of both language runtimes and web servers, that enhancements to either can offer performance improvements to the community. Acknowledgements We are
42、 appreciative of the many useful discussions with Graeme Johnson and Andrew Low, from the IBM Ottawa Software Lab, which have provided valuable direction. Mathematical guidance from Mei Kobayashi, and perceptive feedback from the Systems Department, both at the IBM Tokyo Research Laboratory resulted
43、 in a more consistent and rigorous analysis. We are also deeply indebted to the feedback and comments regarding PHP and SPECweb2005 testing which we received from the PHP team at IBM Hursley. References 1. Apache Software Foundation (2008), http:/tomcat.apache.org 2. Bergsten, H.: Java Server Pages.
44、 O Reilly, Sebastopol (2003) 3. Cecchet, E., Chanda, A., Elnikety, S., Marguerite, J., Zwaenepoel, W.: Performance Comparison of Middleware Architectures for Generating Dynamic Web Content. In: 4th ACM/IFIP/USENIX International Middleware Conference (2003) 4. Chopra, V., Galbraith, B., et al.: Profe
45、ssional Apache Tomcat (2003) ISBN 0-764-5372-5 5. IBM (2006), http:/ 6. Johnson, S., Huizenga, G., Pulavarty, B.: Performance Tuning for Linux Servers. IBM Press (2005) ISBN 0-131-44753-X 7. Lecky-Thompson, E., Eide-Goodman, H., Nowicki, S., Cove, A.: Professional PHP5. Wrox Press (2005) ISBN 0-764-
46、57282-2 8. Petrini, F., Kerbyson, D., Pakin, S.: The case of the Missing Supercomputer Performance:Achieving Optimal Performance on the 8,192 Processors of ASCI Q. In: Proceedings of IEEE/ACM SC (2004) 9. PHP Group (2008), http:/ 10. Ramana, U., Prabhakar, T.: Some Experiments with the Performance o
47、f LAMP Architecture. In: Proceedings of the 2005 Fifth International Conference on Computer and Information Technology (2005) 11. Security Space (2007), http:/ 12. Standard Performance Evaluation Corporation (2008), http:/www.spec.org 13. Titchkosky, L., Arlitt, M., Williamson, C.: A Performance Com
48、parison of Dynamic Web Technologies. In: 11th IEEE/ACM International Symposium on Modeling, Analysis and Simulation of Computer Telecommunications Systems (2003) 14. Wainwright, P.: Professional Apache 2.0 (2002) ISBN 1-861-00822-1 15. Wu, A.W., Wang, H., Wilkins, D.: Performance Comparison of Alter
49、native Solutions For Web-To-Database Applications. In: Proceedings of the Southern Conference on Computing (2000) 16. Garcia, D.F., Garcia, J.: TPC-W E-Commerce Benchmark Evaluation. IEEE Computer 36(2), 52 48 (2003) 17. Amza, C., et al.: Specification and implementation of dynamic Web site benchmarks. In:Proceedings of the 5th IEEE Workshop on Workload Characterization (2002) 18. Warner, S., Worley, J.: SPECweb2005 in the Real World: Using Internet Information Server