Saturday, July 04, 2009

The world diffusion of Php

This article was updated at Sep 14, 2009.

Php, the language of choice of many web applications, powers many of the website that you visit every day: for instance, Yahoo use php. A rapid search on Wikipedia tells that Facebook, Wordpress and Digg are developed in php; Wikipedia itself run MediaWiki, a software written in php. And, obviously, Ossigeno is pure php.

A php based application, if backed by enough processing power, can serve up to million of users, and Facebook and Yahoo stands as a live example of what can be done in this language. The classic point of view for scalability investigate these case studies for know-how on mantaining performance and service availability over a minimum threshold, even if thousand and thousand of requests per second hit the servers. The scalability wall is sometimes hit by other web applications, such as Twitter. However, Twitter does not run on a php platform.
From now on, I'll call the problem scaling up: facing a growing user base which will increase traffic, http requests and bandwidth usage.
No application, written using Php or Ruby on Rails, can scale up over a certain point in the user scale without revisiting completely parts of the architecture. Tipically improvements to the stateless nature of php scripts like memcached and apc are integrated in this phase. Netlog went from using a single database to multiple database and hosts, separating static and dinamic pages access and sharding users data over various servers: extreme measures which are used in very high traffic websites, while for small ones throwing more hardware at the application can solve the issues in an easier way.
Php has already prove to being capable, with proper architecture, to scaling up in the most visited websites of the world. Nowadays there's so much talk and discussion about, everyone thinking to produce the new Twitter, which besides the frequent outages has grown more and more. But the real life of the average web developer it's different, and the majority of the php community is constituted by average Joe's of the web.

What if we don't own Yahoo? Or we are not a Facebook engineer? Php would be still the right choice. Because, Php can also scale down. Let's see an example of the meaning of this two words.
A while ago, I was working on a questionnaire that will be used from small firms to see if they are affected by new Italian business laws - and so needing my customer to outsourcing him waste disposal. PMIs in my country, where the legislative landscape change every five years, frequently outsource some processes to not infringe laws and don't have to worry a bit.
I made a simple application that basing on a handful of questions produce a basic proposal and gives out my customer contacts: a single php script that in five minutes I deployed on my customer website.
- No compiling needed: besided the application setup, php scripts do not need any particular treatment to become executable.
- Many compatible webservers, also as free hosting; the ability to deploy example projects or prototypes upon outsorced, free web servers is indeed valuable.
- Easy deploying with ftp, svn or scp: only a way to place file on the webserve is needed.
- Easy editing if the customer want a new revision: even if you don't go trough svn, simple hotfixed can be performed directly on the web server with editors like Coda.
Scaling down is the ability of maintain a constant features to time ratio even when the project become smaller and smaller.
If you want to build a full stack web application, we can discuss on the technology which should be used. But if you are developing a two hours project, the choices are limited. If I were a Java programmer I likely would have spent an entire day on it, while compiling and debugging servlets. While if I notice an error in my php single-file script, I correct it and refresh the page. Be pragmatic and use the simplest thing that could possibly work.

Make sure you use the right tool for the job: demagogical and simplicistic rule, but still a very helpful one. Your productivity is certainly affected by technology choices and small applications need to consider php to not become big and complex ones.

No comments:

ShareThis