PHP vs. Java are there energy consumption differences?

Viewed 3246

I heard a rumor, that Java consumes less energy than PHP and was wondering if and how this would be true. I'm currently working in a company where we base most of our apps on PHP. Power consumption has never been the problem for us, but we are working on bigger projects where it might matter. We love PHP for web developing and are wondering how such a rumor can spread and if it is true at all.

The example I heard was that Facebook is switching for exactly that reason to Java (I can't seem to find any of this stuff on google though).

Since a customer of mine is asking me this question I would love proof if it is true.

13 Answers

Yes, Java beat PHP in term of power consumption and speed (and any other interpreted language).

But the relation to power consumption and speed is not has trivial has it first seem.

Is a faster language, a greener one?

It's complicated.

Traditionally, performance in software languages was in almost all cases synonymous of fast execution time. Recently energy become also a key metric.

The study Energy Efficiency across Programming Languages - How Do Energy, Time, and Memory Relate? highlight that counterintuitively faster is not always greener.

A very common misconception when analyzing energy consumption in software is that it will behave in the same way execution time does. In other words, reducing the execution time of a program would bring about the same amount of energy reduction. In fact, the Energy equation, Energy (J) = Power (W) x Time(s), indicates that reducing time implies a reduction in the energy consumed. However, the Power variable of the equation, which cannot be assumed as a constant, also has an impact on the energy.

Normalized global results for Energy, Time, and
Memory

Choosing a language if speed and energy are the only factors is easy. But it's not when memory is also an issue.

Pareto optimal sets for different combination of objectives.

Related