it seems that most of the time, the speed gained is not worth it -- is it so? otherwise many people will do it for their most popular page. Is there real benefit of using a C program. I can think of a case where it is not important: when the network bottleneck on the server is quite bigger than the CPU bottleneck, then how fast the program runs becomes less important.
Most websites use caching in memory for high speed response. In this case the load is not in the creation of the page anymore so I wouldn't go for c program.
I would say, even in the case that you illustrated, it would never be worth it to redesign your server side work to run as a C program. Regardless of the amount of traffic.
The cost of upgrading your server or implementing effective caching will always be less than the work it would require to write rewrite your server side code to run in C.
C is an excellent language. But it was designed for systems level programming not making web pages. PHP on the other hand was designed for making web pages. Use the right tool for the right job. In this case PHP.
Also you're starting with a faulty premise. Namely that PHP won't be fast enough to deliver the page content. There are a multitude of websites out there that simply disagree with that statement. Maybe there is some corner case out there that C is the only choice for the job but I find it highly unlikely that you are going to run into that scenario.
it really depends on the code. For instance, I'd rather compile C code that deals with my network graph algorithm; however, i'd never convert a simple static page that displays minimal CSS.
When you use C as a hammer, everything looks like a thumb.
As Jared stated above, use the right tools. You could do it all in C, many have. But the development speed of PHP vs C for the web is something you might look into also. Something that is pretty simple to do in PHP (dynamic array's for example) is something that is not simple in C.
If you even need to ask the question, the answer is no.
Web based apps are limited by network, database, i/o, and CPU, in that order, and the speed increase you would get by writing your code in C would certainly be offset but the increased development time, due the nature of the language, and still be affected more markedly by those other factors.
If your code needs to run really fast, doing something quite computationally difficult or involved, perhaps C could be the right answer, but most web sites are not like this.
It could be worthwhile having very specific processing or heavy lifting code rewritten as C modules once it is determined that the current implementation is too slow, but these optimisations are best done down the track, with sure knowledge of the real bottlenecks in the app.
If you have a decent library or platform eg .NET MVC, using C# for general web dev is a feasible idea. C, not so much.
There is one scenario (and in all other cases I can think of, the answer is that it won't worth it -good reasonings are in the other answers).
So the case is when
- the program needs to do a lot of data processing or calculations
- there are heavily optimized C codes available
I'd say a complex raytracing system is a candidate for the situation, but nothing under the complexity of this.
Even in this case, I'd implement the pages in PHP and run a background job to do the heavy lifting.