Zhao has highlighted that PHP as an interpreted language use more CPU and memory than compiled languages. You can see the full article here: https://developers.facebook.com/blog/post/358/
Is this means that If we have a large application and we did not use HipHop will it cost more than if it was written in ASP.NET because of the high use of CPU in PHP?
Yes and no.
(Before I forget, I'm glad you brought this up. I remember reading about it a while back and wanted to give it a try, but forgot. =p)
If you write the same line of code in a compiled language and an interpreted language, the compiled language will always be faster. That's a fact... no getting around it. An interpreted language has an extra step where it has to read it and convert it to something that is compiled-like before it can act on it.
However, when you are dealing with ASP.NET and PHP explicitly, things get a little trickier.
Where I work, we actually have both running. We have a back-end developed by a third-party that uses Microsoft stuff, and thus ASP.NET. I'm our in-house developer and just about everything I do (web-based) is done in PHP.
Until recently, we had PHP running on Windows, using FastCGI. We also (obviously) had ASP.NET running in Windows.
I redid the portion of code which was PHP running on Windows (which was there because it had to be local to the ASP.NET for some interaction) to allow us to move it back to a Linux environment.
Before the move, when it was on Windows, the PHP was painfully slow. Once we moved it to Linux, it is now blazing fast (previously, the CPU would max out the CPU on the Windows system which had 8 cores and something to the order of 64+ gigs of RAM). On the Linux box, which has 4 cores and 8 gigs of RAM, it doesn't even go over .1% CPU usage (most of the time, it doesn't even go over .01%).
The ASP.NET does just fine on Windows, but runs steady at a few % CPU usage.
ASP.NET is compiled, and does some things faster. However, it also has a MUCH higher overhead cost (for example, ASP.NET has an AJAX Framework -Service- which runs on the server). This means you need a stronger machine to power the ASP.NET compared to PHP. Also, Windows (which ASP.NET requires) itself has more overhead than Linux.
This higher overhead somewhat offsets the difference in speed between the two (in most cases).
Also, when you say a "large application", you could be talking about several scenerios:
- A system which has many components, but most components are independent of one another for each particular page.
- A system which has one very large component which is run in most cases.
In the first case, even though there is a lot of code, only a fraction of it is being used at any one time, which you could (for this argument) consider as a collection of small applications. In this case, the boost in speed would be relatively minimal. This is the scenario which probably accounts for the vast majority of applications (and many that it doesn't apply to could probably be refactored to fit this scenario).
The other scenario, the one large component, is the situation in which compiled could greatly out-weight an interpreted language. In these cases, ASP.NET might have an edge of PHP. However, the overhead needed for ASP.NET is something that must be kept in mind.
There are also ways to offset the cost of a large component. For example, I've created a bit of code which lets me cache the output of parts of a PHP program which are common to all users. This lets me reduce the processing for each page somewhat (the actual amount varies greatly depending on the tasks being performed, but could be between 5-99% in some cases).
Assuming that if we have 1 server and we are running let's say a start up facebook. One server will be windows and running that facebook on ASP.NET and the other will be Linux running that facebook on PHP (so the same functionality but in two different languages and resources).
Which one will use less resources and CPU? Which one will cost less?
It's impossible to say because there a millions of facets that go into an application like facebook, and there are good and bad ways to write code in either language which will consume vastly different amounts of server resources. In short, there are too many variables involved to give you an answer.
I would encourage you not to use the sheer speed of a language (as presented in benchmark tests) as a reason to use one language over the other. There are many good and bad things about any language, and many more important factors to take into consideration when choosing one. There are also many optimizers and things you can do to use fewer server resources if that becomes a problem later. Servers and hardware are cheap, and getting more traffic than a single server can handle is always a good problem to have
I don't think the cost would differ based on the technology used much.
Only thing to note here would be, PHP hosting seem to be littler cheaper then windows hosting considering comparable features.