Performance check for PHP Vs JSP

Here I'm going to discuss about the PHP and JSP performance technically, this is a summary what I found from the googling about the performacne check on PHP vs JSP. But actual results may vary from this but not as the whole, according to my past experiences working with PHP and JSP I could sort-out some possible language issues in technically.

Arithmatic Operations

We know Java arithmetic operations are optimized well, it will request/respond to CPU with direct instruction, numerical are greater performance and arithmetic operations are very smooth.
PHP is a weak type of variables, arithmetic operations are unsatisfactory, it is estimated that is not directly correspond to the binary arithmetic operations like does in Java.

PHP guess the process of arithmetic operations are as follows, in computing the need for testing before it is numerical variables, and to convert non-numerical values, for example, PHP can do this kind of calculation: 100 + "zhoutang", the result of 100. It is precisely because it is weakly typed languages, together with the pre-op testing and conversion, thus resulting in lower performance of arithmetic operations. This is hardly impact on performance.

String Handling

Java string to deal with the object, it is clear that in the case of a string comparison, Java is far worse than PHP. (Because the string operation, it is most to be done to connect, only connect computing comparison, a rough comparison of what the other substring, not a big difference between the two)

PHP string operations, it is estimated that many of the string directly call C functions, so that efficiency would be much higher.

In WEB development,  connection string is very frequent operation (including the SQL string generate), so arithmetic operations and string in both computing, Java (JSP) advantage would not be obvious, but PHP have their own director.

Database Access

What is a connection pool?

In software engineering, a connection pool is a cache of database connections maintained by the database so that the connections can be reused when the database receives future requests for data. Connection pools are used to enhance the performance of executing commands on a database. Opening and maintaining a database connection for each user, especially requests made to a dynamic database-driven website application, is costly and wastes resources. In connection pooling, after a connection is created, it is placed in the pool and it is used over again so that a new connection does not have to be established. If all the connections are being used, a new connection is made and is added to the pool. Connection pooling also cuts down on the amount of time a user must wait to establish a connection to the database. - from Wikipedia

In PHP when we use persistent connection (pconnect), performance of the connection pool is equivalent to Java, many PHP programmers have even heard of this concept.

However, having said that, pconnect principle, and the connection pool in a similar vein is the procedure to close connection, but PHP does not really shut down, once again opened, the direct use of available connections.

However, PHP is indeed the realization of much more convenient than Java, simply add the letters on the easy to achieve, Java is some trouble, Configuring Tomcat's connection pools are costs some time.

Can be seen that the database operation, open the connection is a waste of resources. JSP database connection is much more overhead than PHP.

File Handling

JSP is farmore better then PHP ;). Try it by yourself.


Generally speaking, PHP and JSP performance, the difference can not be very far away, each with its own advantages.  Although the implementation of JSP is complied, to pass JVM will performance declined.From the function, JSP some of the relatively strong, mainly because of the support of Java, in a number of very large-scale enterprises, there are advantages of using JSP (Java support is there), but in general the application of business or general, PHP full able to cope with.

In addition, PHP is more than easy to use JSP. For individuals that do the same WEB system, PHP is relatively easy than JSP, the complexity may be lower (JSP to use as technology, the estimated structure of the environment, system design may have trouble, but the PHP technologies and products more open and loose, at least I think that the Tomcat documentation do not Apache or PHP at all.).

PHP compact and flexible, JSP has become vast, and the concept is for large system, personally I think that the technical complexity of deliberately exaggerating the degree of suspicion.

In addition, PHP can use Zend, Zend to enhance PHP performance to about 100% or so. Arithmetic operations is estimated to raise a grade, and other operations, a maximum of about 30-40% raise.

What you think about this JSP over PHP? :o)