In this tutorial you will know the scalability of PHP and also comparison of PHP Web Architecture with J2EE architecture.

In this tutorial you will know the scalability of PHP and also comparison of PHP Web Architecture with J2EE architecture.

PHP Vs Java

Those who think that java scales and PHP not is wrong, PHP it needs someone to explain the truth that it does scale. Those who is open minded and interested to putting their web development skills in building applications is easy-to-write, easy-maintain, cross-platform, scalable PHP platform, but has hesitation due to scalability myth. Lets start by looking this term scalability.

Scalability can be measured in number of different aspect. It always point to the performance, maintainability, fault tolerance and availability of programming staff. These all are issues must be considered in choosing development platform of a large project. I would like to explain this scalability to its core concern performance.

Language And Database Performance

Both PHP and Java runs on virtual machine. Java beat PHP on some performance benchmark substantially. However overall the two languages are not in order of magnitude difference. In earlier the PHP did not support OOP feature until PHP4. But now a day it supports both OOP (Object Oriented programming) and procedural programming. Novice web programmer often does not understand the MVC architecture. They does their all work in one PHP file such as database query and printing their results with loops.
The performance also depends on database connection. The database connectivity in PHP is consists of either database abstraction layer called PEAR::DB or a thin layer on the top C data access function.

Comparing Architecture
The three basic web architecture which is commonly used today are two-tear architecture, logical three-tear architecture and physical thee-tear architecture.

J2EE Web Server Architecture
J2ee application structure looks very clear, for example JSP (Java Server Pages) communicate to EJB (Enterprise Java Bean), which further communicate to Database. The J2EE topology used in communication (Between EJB and Database) could be anything but clear. The comparison can only be valid where J2EE scales and PHP not.

Sun?s EJB 1.0 architecture for web application servers

The above diagram is classical view of three-tear architecture. It consumes a lot of network traffic either by a database connection or via remote method invocation. It pays performance price. When the first version of JSP and EJB were released, the prevalent web server was Tomcat 1.x, its process model was not compatible with java threading model. It was non-trivial performance overhead for those who decide to adopt it. The RMI (Remote Method Invocation) connection between EJB layer and Servlet was more significance of overhead. A page containing ten fields from twenty of object would make two hundred RMI call to complete it. This Overhead was removed in EJB 2.0 architecture.

EJB 2.0 Architecture

The above architecture is logical three-tear architecture.

PHP Web Server Architecture

The early version of PHP could abstract all the business and database logic into functional three-tear architecture. The more recent version could abstract the business logic with object and now with PHP 5 these objects can use protected, private and public user control. PHP has always been capable of running the gamut between two-tear architecture and logical three-tear architecture.

A modern PHP architecture, strikingly similar to the EJB 2.0 model

The modern PHP code is in progress with server as with java web server. So there is no any overhead on server communication to PHP code. In PHP architecture the PHP page acts as broker between second-tear business objects and smart templates, which is used to format the page presentation.

Stateful and Stateless Architecture

To store the application session object, PHP uses database as a back end session store. Because a network access is required, therefore a little performance difference comes.

The Java pattern is the use of a local persistent object store on each web server. The user is limited to a single server by use of sticky sessions on the router. The same could be done in PHP. An ideal multi-server architecture is POD architecture. Here minimum session store on the database because the router round-robins each of the machine. The key of success is not any particular technology, but simplify your server model to understand all the component of application layer who spend time in optimizing the server architecture is flexible with both PHP and Java.

The Convergence of Web Application Architecture

By the fact that both PHP and J2EE are conversing on same design, the argument of PHP scalability is further simplified. If you want to scale the performance principle for the scalability then web pages should be served quickly. In order to server web page quickly and efficiently you either have to do less overhead task or you do faster. PHP is faster as compared to java. For open-minded developers there is a lot of application that can be build cheaply, robustly, quickly and scalability with PHP. Even Yahoo has also adopted PHP as its language for development. So don?t believe on hype that PHP isn?t for real applications development or doesn?t scale.