Friday, July 3, 2009

Should Server-side scripting or client side scripting for high volume websites?

Javascript is client based and although it’s useful for AJAX and relies on the browser to be executed the use of Javascript makes the website and it’s developer depend on the client’s system (an unknown) to determine website performance.

The Post Hypertext Processor (PHP) is a server side language programmed initially as a bunch of CGI scripts complied in C/C++, as such it’s a very efficient language.(Echo3)[i] The primary platform for web-development with PHP Is LAMP (Linux, Apache, PHP and MySQL);(Dougherty)[ii](NetCraft)[iii] As with any programming language and website more than just the language must be considered to determine overall system performance with respect to the website expierence. An example of this is if we have the world most powerful supercomputer but only a dial-up connection no one will host web-sites on said computer.

There are far more factors in performance than just the language; how many users are there? How much Bandwidth is there? What’s the local carriers’s data load during the hours of testing?

If we conduct an “Apples to Apples” comparison of PHP vs Javascript where all factors are equal; PHP will come out far faster as it’s a dedicated framework of byte-compiled code operating within the CGI vs code that is compiled within the browser.(WrenSoft)[iv] When we examine the underlying frameworks and architectures we find that this has been a longstanding debate. PHP is based in C/C++ where as Javascript is a derivative in Java; if we compare execution times of C/C++ vs Java we see that even with just in time compilation we are trading platform compatibility for performance. (Lewis et al.)[v] In short we may reify the issue as follows in a logical question;

Is it faster to compile once and execute many times upon request or to compile code at every execution after downloading it’s source?

When considering performance and saleability; we must look to the medium being utilized and it’s architecture; LAMP platforms host most of the internet ; Facebook, MySPACE, Google, Amazon, Ebay, all use LAMP based architectures with custom CGI-Scripts; these are by far the largest and most used and abused sites on the internet, the major difference between these is that the databases they use are quite large and distributed; the notion of using a Database to render dynamic content did exist before PHP but PHP became the “Defacto” dynamically generated database driven website framework via templates; as for saleability with the use of “DNS Round Robin” and PHP via MySQL clusters allows PHP to scale into the millions of hit’s per minute across multiple hosts; to further improve performance one may utilize geo-location to ensure that a low latency server is chosen for a given domain that remains close to the client DNS request. Microsoft has no comparable product, and Oracle recently bought out Sun to ensure that MySQL would become one of their products because of this technical “Niche”.

References


[i] N.a. (Echo 3 Services, July 7th 2002) Origins of PHP [Online] World Wide Web, Availalbe from: http://michaelthompson.org/weblog/pages/Origins_of_PHP.html (Accessed on June 2nd 2009)

[ii] Doughtery, Dale (Onlamp, January 26th 2001) LAMP The opensource web platform [Online] World Wide Web, Available from: http://www.onlamp.com/pub/a/onlamp/2001/01/25/lamp.html (Accessed on June 2nd 2009)

[iii] N.a. (Netcraft, 2009) Market Share for all servers across domains [Online] World Wide Web, Available from: http://news.netcraft.com/ (Accessed June 2nd 2009)

[iv] N.a. (Wrensoft 2008) Search Benchmark Informaiton & Comparison [Online] World Wide Web, Available from: http://www.wrensoft.com/zoom/benchmarks.html (Accessed on June 2nd 2009)

[v] Lewis, J.P.; Neumann, Ulrich; (University of Southern California) Preformance of Java vs C++ [Online] World Wide Web, Availalbe from: http://www.idiom.com/~zilla/Computer/javaCbenchmark.html (Accessed June 2nd 2009)