A Comparative Study between Dynamic Web Scripting Languages ...

7 downloads 152609 Views 215KB Size Report
Abstract. Nowadays websites generate dynamic responses to the user requests. This leads them to dynamic web scripting languages. PHP, JSP and ASP.
A Comparative Study between Dynamic Web Scripting Languages Alok Ranjan1, Rajeev Kumar1, and Joydip Dhar2 1

Department of Information Technology 2 Department of Applied Sciences ABV - Indian Institute of Information Technology and Management, Gwalior, India {iiitm.alok,rajeevkumariiitm}@gmail.com, [email protected]

Abstract. Nowadays websites generate dynamic responses to the user requests. This leads them to dynamic web scripting languages. PHP, JSP and ASP.NET are the three most popular web scripting languages in the world. PHP is particularly useful for lightweight web applications. JSP which employs Java in its implementation is useful for the systems which require extra security. ASP.NET which is a Microsoft product combines some of the fine features of both PHP and JSP. All the three languages have pros and cons associated with them. In this paper, we have compared the impacts of these three languages on the performance of a web server. We have described and analyzed the results of conducting experiments on four benchmarks: calculating the factorial of 100, determining whether a random word having 1 million characters is a palindrome or not, sorting a list of 1 million random integers using merge sort, running Dijkstra’s algorithm on a graph with 1000 nodes and 5000 edges. We employed famous web servers viz. Apache 2.2.6, Apache Tomcat 6.0.26 and IIS 7.5. We have shown the results using both built-in modules and self-written codes. Moreover, we have used C# with ASP.NET which being an object oriented language provides built-in modules. Keywords: ASP.NET, Dijkstra’s Algorithm, JSP, Merge Sort, PHP.

1

Introduction

HTML, which stands for Hyper Text Markup Language is a text and image formatting markup language employed by web browsers to format web pages. It was first proposed by Tim Berners-Lee [1, 16]. It has become exponentially more popular since then, expanding beyond a small group of computer-science visionaries to the personal and business sectors. Today, it’s almost a household word. As the utilization of World Wide Web intensified, static HTML web pages were rendered inadequate considering the growing requirements of mankind [2]. Earlier, web servers used to employ the basic HTTP protocol. Once they received a client request, they would reply with a static document containing only HTML content. However, gradually massive content began to be required which had to be saved on the web server. This led in the consumption of heavy storage area at the server side for big applications thus culminating into the waste R. Kannan and F. Andres (Eds.): ICDEM 2010, LNCS 6411, pp. 288–295, 2012. © Springer-Verlag Berlin Heidelberg 2012

A Comparative Study between Dynamic Web Scripting Languages

289

of resources at the server side [3]. As a remedial measure, dynamic web scripting languages were introduced. A dynamic web scripting languages is a language which reacts to a user’s action. They are used to embed interactivity to otherwise static Web pages. They can also automatically fill up parts of Web-based forms, among other uses. Science zine [4] described the capabilities of JavaScript, a popular Web scripting language: "Without any network transmission, an HTML page with embedded JavaScript can interpret the entered text and alert the user with a message dialog if the input is invalid. Or you can use JavaScript to perform an action (such as play an audio file, execute an Applet, or communicate with a plug-in) in response to the user opening or exiting a page." One of the first dynamic scripting languages was Common Gateway Interface (CGI). Using CGI the web programmers were able to produce scripts which were able to read input parameters and return an HTML page meeting specific user requirements) [5]. Development of CGI led to the hunt for more sophisticated and robust web scripting languages. PHP (Hypertext Preprocessor) followed the era of CGI. It is one of the most heavily used dynamic web scripting languages in the world. It is widely used to implement lightweight web applications and to access databases and other kinds of middleware. It was originally developed by Rasmus Lerdorf in 1995 [6]. It is open source software released under the PHP license. It can be easily embedded into an HTML source document. Then after, it can be interpreted by a web server with a PHP processor module generating the web document. JavaServer Pages (JSP) is a technology which uses Java as supporting language. It aims at allowing programmers to utilize the vast capability of Java in building their web applications [9]. It by released by Sun Microsystem in 1999. It may be considered as a high-level abstraction of Java servlets. JSP pages are loaded in the server and operated from a Java server packet, often packaged as a .war or .ear file archive. It allows Java code and certain pre-defined actions to be intermixed with static web markup content, with the resulting page being compiled and executed on the server to deliver an HTML or XML document. The compiled pages and any dependent Java libraries use Java bytecode rather than a native software format, and must therefore be executed within a Java virtual machine (JVM) that integrates with the host operating system to provide an abstract platform-neutral environment. ASP.NET is a web application framework designed by Microsoft to facilitate building web sites, web applications and web services. It follows a code behind model i.e. it deals with the dynamic program code by placing them in a separate file or in a separate tag [8]. Thus, it allows the designers and coders to work separately. It permits the programmers to build applications using an event-driven GUI model, rather than in conventional web-scripting environments like CGI, PHP, Python etc. The framework employs existing utilities such as JavaScript with internal components like "ViewState" to bring persistent state to the inherently stateless web environment. The ASP.NET in itself is not a programming language. It is built on a Common Language Runtime(CLR) allowing the programmers to choose any language form a wide pool of languages such as Python , VB.NET, C#.NET J#, Delphi.NET, Chrome etc to code the web application under consideration. A complete list of languages allowed in ASP.NET is given on [10]. The table below depicts a brief comparison between PHP, ASP.NET and JSP based on some general parameters.

290

A. Ranjan, R. Kumar, and J. Dhar Table 1. A brief comparison between PHP, JSP and ASP.NET Area Licensing cost Platform(s) External Hosting Security Scalability Configuration flexibility Framework(s)

PHP Free licensing Multiple Widely available with zero cost Very good Scales very well Extremely flexible Many available

JSP ASP.NET Free licensing Costly Licensing Multiple Windows only Not so available Widely available although free although requires fee Good Good Scales well when Can be difficult to configured properly scale Moderately flexible Not very flexible Standard framework

Standard framework

The table given below depicts sample codes of PHP, JSP and ASP.NET outputting Hello World! Table 2. Examples of PHP, JSP and ASP.NET scripts with HTML PHP Script

JSP Script

ASP.NET Script

HTML result Hello World!

In this paper, we intend to study the impact of three different and famous web scripting languages viz. PHP, JSP, ASP.NET on the performance of a web server. Although a wide variety of languages can be used with ASP.NET, in our study, we have used C# along with it. We conduct experiments on some standard benchmarks using both built-in modules and self- written codes. 1.1

Client Server Architecture

Client–server model of computing is a sort of distributed application structure [7].It is used by almost all the web scripting languages. The languages discussed in this paper also use it. In this section we provide an overview of this architecture. Client server architecture divides the workloads between different service stations known as servers, and service requesters, called clients. Generally, servers and clients communicate over a network; however, they may lie on the same system. Such systems in which servers and clients lie on the same machine are called virtual machine. A server machine is a host which is running one or more server programs sharing its resources with clients. A client shares none of its resources. However it can always request a server's content or service function. Clients, hence, initiate communications with servers. Fig. 1 depicts the Client –Server architecture over the World Wide Web.

A Comparative Study between Dynamic Web Scripting Languages

291

Fig. 1. Client Server Architecture

In our experiments, we have used the client- server architecture having both clients and servers residing on the same system. These types of systems are advantageous for debugging and testing purpose of web script language programming. While building any application, a programmer can test on his own computer whether the application is working as per his expectations or not. If not, he can change the application right on his computer. These tasks can be performed without the overhead of uploading the codes on any distant server time and again. Examples of such systems include LAMP, WAMP, and SAMP etc.

Fig. 2. Client and Server on the Single PC

292

2

A. Ranjan, R. Kumar, and J. Dhar

Literature Survey

There has been a heavy research evaluating the performances of static and dynamic web contents. In paper [11], a sophisticated study was performed about the effect of dynamic contents on the performance of web servers. It was revealed that it is extremely slow to retrieve a web page when coupled with a dynamic scripting language, in this case Common Gateway Interface (CGI), than when it is a plain static web page. In paper [12], the authors concluded that the personalization of web pages comes at a price. The processing required for dynamic web pages and the overhead arising out of the database access often result in a negative impact on the performance of the web server. The authors have quantified each of these effects. They determined that these effects as a whole diminish up to a factor of 8 the highest request rate bolstered by any user. The results obtained by them suggested that Java outperformed both PHP and Perl. They also inferred that web server performances under overload can be quite unpredictable. They also concluded that PHP, Perl and Jetty which are dynamic content generation technology are quite robust while some other technologies such as Resin are not. In paper [13], Ramana studied the performances of MySQL and PHP components in the Linux environment using LAMP (Linux, Apache, MySQL, PHP) architecture. They built a web application with the help of LAMP and measured the performance with respect to the application. They quantified the improvement in performance that would increase if one was coded in C as against PHP. They also did some application level benchmarking comparative study on the performance of the application on Linux and Windows environments. They concluded that Apache outperforms Windows with IIS when the program was coded in PHP and the persistence was with MySQL. They also showed that Windows armed with Apache, PHP and MySQL falls in between. Cecchet et al., in paper [14], compared three middleware architectures for generating dynamic web contents: PHP, Java servlets, and Enterprise Java Beans (EJB). They attached PHP to the Web server. They set the database interfaces in PHP to be adhoc and wrote it separately for each and every database. They determined that Java servlets execute independently rendering independence from any particular database. They achieved so doing all database operations using JDBC. EJB employed a component based approach which was platform-independent. It divided the business logic and the presentation logic in different tiers. Also the code for auction site using Java servlets was lengthier than that employing PHP implementation. The same holds for the online bookstore. They concluded that Java tools and safety properties associated with it did help in debugging, but it also required multiple re-casts posing many trade-offs between typed and untyped languages. Although EJB was determined to be quite easy to use, as it did not require written SQL queries, the implementation done by the authors required more lines of code in Java than in that required in servlets. It was due to the fact that they required many interfaces which were required to be implemented to structure the application logic into beans. PHP scripts were determined to be more efficient than Java servlets in terms of performance. However, PHP scripts were tied to the Web server and provided limited functionality and runtime support whereas Java servlets execute in a different process from the Web server. The authors used it to achieve better performance when web server is proved to be the bottleneck. The authors determined that servlets can be used to improve performance if there is database lock contention application. They also concluded that EJB offers the most flexible

A Comparaative Study between Dynamic Web Scripting Languages

293

architecture. EJB offers maany software engineering qualities such as modularity, pportability, and maintainability y. However it was determined that the EJB is less efficiient than the Java servlets and PHP. P In paper [15], the authorrs presented three benchmarks for dynamic web sites w with differing characteristics: an n online bookstore, an auction site, and a bulletin boaard. They carried out bottleneck k characterization of the benchmarks.

3

Experiments and d Analysis

In order to compare the perfformances between PHP, JSP and ASP.NET, we have uused the following versions of th he languages under consideration. These are the latest vversions of the above three lan nguages. • • •

PHP 5.3.2 JSP 2.1 ASP.NET 4.0 (Miccrosoft .NET framework)

In order to carry out the ex xperiments, we have used a machine possessing 1 GB m main memory and a 1.83 GHz du ual core processor with windows XP service pack 2 as the operating system. We used Apache A 2.2.6, Apache Tomcat 6.0.26 and IIS 7.5 as the w web servers. l on the basis of the following four benchmarkss, We compared the three languages • •

Finding the factoriial of 100 (factorial benchmark). Determining wheth her a random word having 1 million characters is a paalindrome or not (palin ndrome benchmark). Sorting a list of 1 million random integers using merge sort [17] (merge sort benchmark). Running Dijkstra’ss algorithm on a graph with 1000 nodes and 5000 edges [[18] (Dijkstra benchmaark).

• •

250 200 PHP 5.3.2

150

JSP 2.1

100

ASP.NET 4..0 50 0 Factorial

palindro ome Merge Sort

Dijkstra

Fig. 3. Execution time using self- written codes

294

A. Ranjan, R. Kumarr, and J. Dhar

300 250 200

PHP 5.3.2

150

JSP 2.1

100

ASP.NET 4.0

50 0 Factorial

palindrome

Merge Sort

Dijkstra

Fig. 4. 4 Execution time using built-in modules

We conducted experiments on the above four benchmarks using the three languaages under consideration. We useed both self-written codes and built-in modules of the abbove four benchmarks in all the three languages. In ASP.NET we actually used C# siince ASP.NET in itself is not a language l rather it is a framework. We conducted 1000 ttests on each benchmark with eacch language and calculated the total runtime of the executiion. Fig.3 depicts the total ex xecution time of the three languages over 1000 tests on the four benchmarks using selff-written codes. Similarly Fig. 4 depicts the total executtion time of the three languagees over 1000 tests on the four benchmarks using buillt-in modules.

4

Conclusions and Future Work

We carried out sophisticateed experiments to ascertain the performances of three w web scripting languages viz. PH HP, JSP and ASP.NET. We have shown the results in Figg. 3 and Fig. 4. Fig. 3 depicts th he experimental results for the self-written codes while the Fig. 4 depicts the experimental results for built-in modules. It can be easily concluuded from the graphs that no lan nguage excels under all circumstances. If we consider numerical calculation, we can conclude that PHP works the best out of the three languaages under consideration as sho own by the actions of the three languages on factoorial benchmark. It holds for both h self-written codes and built-in modules. On the contraryy, if we consider comparison baased problems such merge sort, JSP comes out to the cllear winner out of the three lang guages for both self- written and built-in modules. One can infer, in case of complex problems p such as Dijkstra’s algorithm and problems ppertaining to string manipulatiions such as palindrome checking that ASP.NET perforrms stupendously. In our experiments, we have h used C# as the supporting language in ASP.NET ..We know that we have a very laarge pool of languages available to be used as the supportting language with ASP.NET [1 10]. In future, experiments can be aimed at using differrent languages with ASP.NET.

A Comparative Study between Dynamic Web Scripting Languages

295

References 1. Berners-Lee, T., Connolly, D.: Hypertext Markup Language – 2.0, RFC1866, MIT/W3C (1995) 2. Govindaraju, M., Slominski, A., Chiu, K., Liu, P., Engelen, R.V., Lewis, M.J.: Toward Characterizing the Performance of SOAP Toolkits. In: Proceedings of the 5th IEEE/ACM International Workshop on Grid Computing (2004) 3. Berners-Lee, T., Fielding, R.T., Nielsen, H.F.: Hypertext Transfer Protocol — HTTP/1.0, Internet RFC 1945 (1996) 4. Science zine, http://encyclozine.com/technology/computer/internet /web/JavaScript 5. Coar, K., Robinson, D.: The WWW Common Gateway Interface version 1.1, Internet draft (1999) 6. Lerdorf, R.: Programming PHP. O’Reilly Media, California (2002) 7. Berson, A.: Client/server architecture. McGraw-Hill Companies, New York (1992) 8. MacDonald, M.: ASP.NET: The Complete Reference. McGraw-Hill Companies, New York (2002) 9. Hanna, P.: JSP 2.0: The Complete Reference. McGraw-Hill Companies, New York (2003) 10. dotnetpowered Language List, http://www.dotnetpowered.com/languages.aspx 11. Yeager, N., McGrath, R.: Web Server Technology: The Advanced Guide for World Wide Web Information Providers. Morgan-Kaufmann Publishers, Inc., San Francisco (1996) 12. Titchkosky, L., Arlitt, M., Williamson, C.: A Performance Comparison of Dynamic Web Technologies. In: 11th IEEE/ACM International Symposium on Modeling, Analysis and Simulation of Computer Telecommunications Systems (2003) 13. Ramana, U., Prabhakar, T.: Some Experiments with the Performance of LAMP Architecture. In: Proceedings of the 2005 Fifth International Conference on Computer and Information Technology (2005) 14. Cecchet, E., Chanda, A., Elnikety, S., Marguerite, J., Zwaenepoel, W.: Performance Comparison of Middleware Architectures for Generating Dynamic Web Content. In: Endler, M., Schmidt, D.C. (eds.) Middleware 2003. LNCS, vol. 2672, pp. 242–267. Springer, Heidelberg (2003) 15. Amza, C., et al.: Specification and implementation of dynamic Web site benchmarks. In: Proceedings of the 5th IEEE Workshop on Workload Characterization (2002) 16. Berners-Lee, T.: Information Management: A Proposal, CERN (1990) 17. Dijkastra, E.J.: A note on two problems in connection with graphs. Numerische Mathematic, pp. 269–271(1959) 18. Knuth, D.E.: Sorting by Merging. The Art of Computer Programming. Addison-Wesley, Massachusetts (1998)