Thread: Why PHP?
View Single Post
Old 2008-05-17, 12:25 PM   #4
cd34
a.k.a. Sparky
 
cd34's Avatar
 
Join Date: Sep 2004
Location: West Palm Beach, FL, USA
Posts: 2,396
A windows hosting company pays $x/year for a professional license for windows. That cost is usually passed on to the client, so, unless there is some massive subsidy coming from somewhere (and there is for a few hosting companies), windows hosting is just going to be more expensive to the client or less profitable to the hosting company.

Since linux is free, (not that you cannot buy support packages), it is very easy for a hosting company to buy a machine, put Linux on it and you've got a system.

Mysql was a free database -- compared to Oracle at $15k and a certified OS (at one point, Sun Unix, SCO or the others were required for their minimal entry point), and you had an opportunity for people to use mysql. Postgresql never took off as well though, it was ACID compliant and Mysql wasn't. That compliance came at the price of performance. Postgresql isn't the laggard that it used to be, but, Mysql grabbed that critical mass early and hasn't really let go.

Apache came along when NCSA was the only real web server software. NCSA was a pain to set up, though, it was menu driven. Apache had these confusing config files, but, was a little more flexible, easier to administrate with automated scripts and quickly became the tool to use. NCSA used to charge money if you hosted more than a few sites on it. IIS comes with Windows, but, you still have to buy that OS, so, there is some inherent cost.

It used to be that if you wanted a dynamic page you had to use Server Side Includes or CGI scripting. Perl was the choice for CGI, and CGI's performance was lackluster. PHP came around because someone wanted a little more power to do things inline on pages. It grew into a more full fledged language and as a result of its simplicity, gained quite a bit of acceptance.

From a software developers standpoint, much of the above forces your hand. You almost have to use apache because it is installed everywhere. If you want to do something sophisticated, and are looking for an external programmer, your pool of talent is much larger for apache than most of the other webservers. That doesn't mean that Apache is the best -- apache has some serious shortcomings for high traffic sites.

There are programmers that love php. php has so many issues internally and zend for the love of god doesn't understand multithreaded programming, but, its a language that allows people to churn out code without much effort or knowledge. It gives results that are adequate most of the time and, in today's society, rather than writing good code, we throw more cpu horsepower at it. Unlike mod_perl or mod_python which embed perl or python interpreters in apache so that your code becomes a part of the webserver, php is interpreted (or, with Zend the compiled bytecode is decoded) each time it is run. For performance, php isn't the answer, but, for someone developing code, being able to restart apache to reload a changed mod_perl/mod_python script isn't always easily available.

As for mysql, when you spoke database, you had flat file, hashed file structures, indexed files or a database. At the time early on, mysql was the popular choice, postgresql was too slow.

These applications all built momentum, and, like it or not, became the standard because of critical mass.

Apache is by far not the fastest webserver out there -- their early charter was 'serve it correctly first, serve it fast later'. While Apache 2.2 and some of their models are much higher performance, their dependency on a straightforward php installation prevents using the higher performance apache models easily. The thought of using php through a fastcgi pipe to gain performance scares a lot of people, and, since Zend doesn't know how to write multithreaded code, if you use apache and don't want to use fastcgi, you're stuck with the slowest of apache's models.

PHP in its own right is poorly written from the ground up. PHP5 has made enormous strides since PHP4, but, its still interpreted. To get a little extra speed out of it, you need to use products you buy from them, or, two modules that Zend tries their darndest to break every release because they cache php bytecode.

There is no best architecture for any solution. The problem is, LAMP is fairly good for 90% of the situations and unless you're doing something extremely out of the ordinary, enough effort can be put into making LAMP work.

Personally, I dislike PHP with a passion. It has its place, but, is by no means a performer. I am not a fan or apache or the tricks required to make it work well. Apache turned down a set of 10 patches from SGI that offered serious performance benefits because it didn't work globally across all of the platforms they supported. Even though apache has their own code that doesn't work across all platforms (Windows Apache loses quite a few capabilities), their developers turned down some significant performance enhancing patches. Some of those patch ideas did make it into some of the apache 2.2 models.

PHP/Zend is in its own little world. Writing code like its 1996 -- and if you want to make your php run faster, buy this software from us which still doesn't come close to the performance you would get out of mod_perl or mod_python.

But, we have to live with what the majority is able to support. As a software developer, if you write code for clients that is expected to run on a virtual server, you can't expect to write an apache module or a mod_perl script that requires a restart when there are changes. You would seriously limit your potential client base at that point, so, you're somewhat stuck with LAMP.

Not all hosting companies will allow you to run different webservers. And there are dozens to choose from. Chromium X-15 used to be the fastest userland webserver out there. nginex is probably the current equivalent. But, probably 2% of the existing market has a real demand for performance like that, though, 100% of the market could benefit from it. The problem is, easily deploying either of those while maintaining compatibility with the applications already written. Zeus is still one of the fastest 'measured' userland webservers out there. Zeus pays for the testing so that they can boast that and they have some very bright programmers working all the time to tweak out every little bit of speed. If it wasn't so expensive, you would see a lot more hosting companies using it for more than just the top-end hosting requirements.

I would replace php with mod_perl or mod_python. And with google releasing their filesystem under the hadoop project, and their compute cluster access being very python centric, python is looking to be good direction, but, you won't find many hosts that allow you to restart apache whenever you make a code change.

I didnt really touch on Java because I am not a fan of Java. Yes, you can write cross-platform applications that run using Java, but, the language structure is cumbersome, and, its performance is average.

In short, there's no real reason you cannot use something other than LAMP, but, you're going against what has built a lot of critical mass and become the de facto standard.

Not that you couldn't write the next killer app and have clients request special setups, but, you might find that clients are hosted where some of those changes might force a hosting plan change.
__________________
SnapReplay.com a different way to share photos - iPhone & Android
cd34 is offline   Reply With Quote