Some Experiments with the Performance of LAMP Architecture

UV Ramana Veritas TV Prabhakar IIT Kanpur [email protected]

Abstract benchmark the architecture, especially at an application level. But, there has been a substantial amount of work Measurements are very useful to gauge the actual done to analyze the performance of some other Web performance of various architectures and their applications. Emmanuel Cecchet et al [1] compared the components. In this paper we investigate the performance of LAMP architecture with the performance of the LAMP(Linux, Apache, MySQL, performance of EJBs and the performance of Java PHP) architecture and MySQL and PHP components. servlets. They performed the comparison based on two We build a web-site using LAMP and measure the benchmarks, RUBiS [2] and RUBBoS [3]. The paper application level performance. We use “measurements [4] talks about the benchmarks that they developed to as a means” to improve the performance of the perform the comparison. The bottleneck . We then investigate the performance of the characterization of the work they have done is application when ported to Windows with running IIS presented in [5]. The work presented in [6] discusses and Apache with MySQL and PHP. the performance and scalability of the EJB applications, by performing experiments with different Keywords: LAMP, performance, software architecture types of EJBs (session, entity etc..) on two different open source EJB application servers (JBOSS and JOnAs). 1. Introduction. C. D. Murta, J. M. Almeida and V. A. F. Almeida [7] presented a performance analysis of WWW Server, A large number of web-sites are built using PHP using WebStone benchmark, in the early days of the and MySQL on the Linux platform with Apache as the inception of the . Arun Iyengar et al. . This combination is known as the LAMP [8] presented a performance analysis of Web server architecture. Apache, PHP and MySQL are also under high CPU loads. In their work Y. Hu, A. Nanda, available on the Windows platform giving rise to and Q. Yang [9] analyzed the performance of Apache combinations like WAMP (Windows, Apache, Web server on a uniprocessor machine and a 4-CPU MySQL, PHP) and WIMP ( where the IIS webserver is Symmetric Multi-Processor (SMP) machine. Vsevold used instead of Apache). In this paper we present the V. Panteleenko and Vincent W. Freeh [10] analyzed results we obtained while investigating some the Web server performance by simulating Wide Area performance issues related to MySQL and PHP and an Network (WAN) conditions. application built with this architecture. There has been some work in the area of client We first investigate the performance of PHP and emulators. The paper by Gaurav Banga and Peter MYSQL modules independently. We then check the Drushel [11] describes a method to generate bursty performance of an application built using these traffic that temporarily exceeds the capacity of the Web components. We then benchmark the application on server. It also describes the problems that one faces WIMP and WAMP platforms. while measuring the Web server capacity. They have implemented a client emulator that can create bursty 2. Related Work traffic, by using a two process architecture. There are quite a few open source client emulators like HTTPerf, Even though LAMP is a very popular architecture EVE etc. Papers [12] and [13] describe the architecture there has been little work to characterize and of these client emulators. Some work is done to compare the performance of From Table 1 we can observe that C is around 400 a scripting language with that of a programming times faster than PHP in almost all the cases. We can language. Ousterhout in his article [14] describes some also see that simple instructions are faster than function of the results he got while comparing the performance call instructions by a factor of around five in case of of TCL/TK with C++, Java and MFC. The sqlbench PHP program and by a factor of around six in case of C suite provided by MySQL can be used to measure the program. performance of MySQL. The URL [15] talks about some of the results that are obtained by using the Table 2. PHP vs C – Time to compute sqlbench suite. 2.8 GHz Machine 3. PHP vs. C Time Taken Ratio

In this section we present the performance of PHP Computation scripting language in comparison to C. The comparison PHP C is done using two different criteria. The first criterion is Fibonacci 290.07 0.6806 426.15 to compare the total number of instructions that a PHP Number program can execute per second versus the number of File I/O 0.1195 0.0098 12.22 instructions that a C program can execute per second. MySQL 0.00125 0.00133 0.942 The second one is to compare the time taken to achieve Access certain functionality using PHP versus the time taken to achieve the same functionality using C. From Table 2 it can be observed that in case of the Fibonacci program, which is computation intensive, C 3.1 Test Bed language performance, is nearly 400 times better than that of PHP. In case of File I/O the performance of C The experiments described here are conducted on still dominates that of PHP, but this time only by a three different machines with different processor clock factor of 10. Finally, in case of MySQL data transfer speeds: P-III 600 MHz, P-III 1 GHz and P-IV 2.8 GHz. even though C performed slightly better in two cases, All these machines had a Linux , with we can say that performance of PHP and C are almost kernel version 2.6.3, PHP version 4.3.4 and gcc version equal. 3.3.2. All these systems have a RAM of 256 mb installed in them. F2. Performance of MySQL can also be substantially improved by eliminating the connection overhead. 3.2 Findings It is known that a access has a connection F1. C performs about four hundred times faster than overhead. The Figure below shows the graph between PHP in case of compute intensive functions. connection overhead and the processing time. From the figure we can observe that the connection overhead is far more than the actual processing time. Table 1. PHP vs C – number of instructions per This implies that if we can avoid connection overhead, second the performance can be improved substantially.

2.8 GHz Machine Instructions per second Ratio PHP C Computation Simple 281147 1383200824 491 Instructions 9 Function call 517227 232404139 449 Recursive 626159 230399042 367 Function

Figure 1.Connection overhead vs. processing time

4. Application benchmark 4.2 Test Bed

We investigate the performance of an application The machine on which the Web server and built with the LAMP. This section describes the database server are running, is a P-IV 2.8 GHz response time and throughput of the Gita Supersite processor, 512 MB RAM with Linux kernel version under different situations. 2.6.3. The Web server used is Apache Web server Gita Supersite (http://www.gitasupersite.iitk.ac.in) version 2.0.48 with PHP module version 4.3.4 loaded is a Web application developed to display the verses into it. The database server is MySQL server version and commentary of Bhagavadgita(an ancient text 4.0.18. The client emulator is running on another containing the essence of Indian Philosophy) in all machine with the same configuration as the server. Indian languages. It can also display the verses in Roman script. The data(Sanskrit verses) is stored in the 4.3 Findings database in ISCII{Indian Script Code for Information Interchange} format and is converted into the font code F3. The maximum throughput that can be achieved for of the desired Indian language to be displayed, when Gita Supersite using the LAMP architecture is around the request arrives. twenty six connections per second on a P-IV machine with 2.8GHz processor. The architecture of the Gita Supersite conforms to As seen is figure 2, the two lines indicate the the trasitional LAMP architecture, except that it has an throughput when there is a limit on the number of extra font conversion module. The font conversion server processes and without a limit on the server module does the font conversion from the ISCII code processes. to the ISFOC (Intelligence based Script FOnt Code) code of the respective language. It then returns the ISFOC data back to the PHP module, which does some formatting work on the data and returns it to the Apache Web server for sending it to the client.

4.1 Application Performance Measurement

The experimental setup consists of a client emulator which pumps in requests to the server running on a different machine and taking the measurements. Methods like sending requests from multiple machines, running multiple processes to pump the requests, Figure 2. Throughput vs. connections per second running multiple threads and sending a request each, from all of the threads etc. do not give the desired F4. We can improve the throughput of these results. In these methods, we have a fixed number of applications by using a machine with more processor clients that are sending requests. Each client has to stop speed, as the CPU is the bottleneck in this case(Fig 3) after sending a single request, receive the response and then send the request again. This method cannot overload the server, because as soon as the server reaches its limiting capacity, it will delay the processing of the client requests.

Gaurav Banga and Peter Drushel[11] described a way to overcome this problem. With this approach, one can send bursty traffic, but one cannot measure the Web server performance accurately. To avoid this problem a sophisticated client emulator has been designed and implemented. Detailed description can be seen in [16].

Figure 3. CPU Utilization

F5. The performance of the Gita Supersite can be F7. The reason for this saturation is the bottleneck in improved by improving the performance of the font the CPU. conversion module, as it is occupying the maximum Figure 6 reflects the CPU utilization as the number portion of the processing time. of connections goes up. CPU reaches saturation level Figure 4 gives an indication of where the time is beyond 200 connections resulting in a drop in the being spent while servicing a request. Most of the time throughput. is going into font conversion. That means we could improve the performance by performing the font conversion off-line.

Figure 6. CPU Utilization vs. number of connections

5. LAMP, WAMP and WIMP Figure 4. Break up the response time We now present the results that we have obtained We then modified the architecture by removing the while running the Gita supersite on the Windows dynamic font conversion step altogether. All the pages platform with Apache web-server, MYSQL an were converted into Devanagari off-line and store in PHP(WAMP) and the Windows platform with IIS web that format in the database. At runtime, the PHP script server, MySQL and PHP(WAMP) retrieves the pages and servers it out. In this situation the architecture resembles more closely to a typical F8. The response time of the WAMP(Windows, LAMP architecture. Apache, MySQL and PHP) and LAMP architectures are almost equal. F6. The maximum throughput that LAMP architecture can support is around 230 on a P-IV machine with 2.8GHz processor. Figure 5 indicates the performance of the site as the number of connections goes up. Saturation is reached and the throughput drops around 230.

Figure 7. Response times of LAMP, WAMP, WIMP

Figure 7 shows the performance of the three configurations with a single connection. While LAMP and WAMP are almost similar, WIMP is trailing

substantially. Figure 5. Throughput vs. connections (without font conversion) 6. Conclusions and Further Work [6] Cecchet etal, Performance and scalability of EJB applications, 17th , Oopsla 2002, Seattle, WA, USA, 4- The objective of this work is to come with some 8 November 2002. numbers that will aid the architect while sizing an application. We could quantify the performance [7] C. D. Murta, J. M. Almeida and V. A. F. Almeida, improvements that would one would accrue if one were Performance Analysis of a WWW Server, to write parts of the code in C as against PHP, the XXII SEMISH, Recife, Brazil, August, 1996 impact of indices in MySQL, and the scaling that would occur with the processor speed. We also did [8] Iyengar etal, An Analysis of Web Server some application level benchmarking and compared the Performance, In Proceedings of the IEEE 1997, performance of the application on Windows and Linux GLOBECOM '97, Phoenix, AZ, November 1997. architectures. Linux with Apache very clearly outperforms Windows with IIS when the business logic [9]Y. Hu, Nanda, and Yang., Measurement, analysis is in PHP and the persistence is with MySQL. and performance improvement of the ApacheWeb Windows with Apache, PHP and MySQL falls in server, Proc. of the 18th IEEE IPCCC, (Phoenix/ between. More detailed results are available in[16]. Scoottsdale, Arizona), pp. 261-267, Feb. 1999.

Some of the future work that can be done is to perform [10] Panteleenko and Freeh, Web Server Performance this analysis on more number of applications and to in a WAN Environment, Proc. of ICCCN, Dallas, TX, increase the validity of the results obtained in this October, 2003. work. The effect of tuning some Linux kernel parameters, on the performance of the LAMP [11] Banga and Drushel, Measuring the Capacity of a applications, also needs to be studied. The impact of Webserver, USENIX Symposium on Internet applying architectural tactics [17] on the performance Technologies and Systems, Monterey, California, of an application will make an interesting study. December 1997

References [12] Mosberger etal, httperf--A Tool for Measuring Web Server Performance}, Hewlett-Packard Research http://www.hpl.hp.com/personal/ [1] Cecchet etal, Performance Comparison of Labs, Middleware Architectures for Generating Dynamic David_Mosberger/httperf.html. Web Content, 4th ACM /IFIP/USENIX International Middleware Conference, Rio de Janeiro, Brazil, June [13] H. Jamjoom and K. Shin, Eve: A Scalable 16-20, 2003 Network Client Emulator, University of Michigan Tech Report, CSE-TR-478-03 [2] RUBiS: Rice University Bidding System URL: http://rubis.objectweb.org [14] Ousterhout, Scripting: Higher Level Programming for 21st Century, IEEE Computer Magazine, March [3]UBBoS: Rice University Bulletin Board System 1998. URL: http://rubbos.objectweb.org [15] MySQL Benchmarks, http:// dev. . com/ tech-resources/benchmarks [4] Amza etal, Specification and Implementation of Dynamic Web Site Benchmarks, IEEE 5th Annual WWC-5, Austin, TX, USA, November 2002. [16] UV Ramana, Some experiments with the performance of LAMP architecture, Masters thesis, IIT [5] Amza etal, Bottleneck Characterization of Dynamic Kanpur, 2004. Web Site Benchmarks, Technical Report TR02-398, Rice University, January 2002. [17] Len Bass, Paul Clements and Rick Kazman, Software Architecture in Practice, Second Edition, SEI Series in Software Engineering, 2003