About the art of building metaphoric solutions to real world problems.
3 Dec
Our world is heading into an ecological disaster and finally it’s not to the governments to change laws in order to stop this from happening – it’s completely our own responsibility. Everyone of us has to expend an effort and change his behavior. I’m glad there is no doubt anymore that the greenhouse effect is man-made and something has to be done.
So let’s start. But what can I change? I’m a senior IT professional like many of you are. Is there anything I can do? And is it even possible to make a profit from it?
Yes, it is! Do what you have been tought in university!
All we have to do is make computers think less. This means to simply optimize your code. We life in a time where hardware is so cheap and powerful that we usually don’t need to think in detail about the performance of the code.
Let’s have a look at an example:
If we write an enterprise application that performs poorly and uses 75% of your CPU’s processing power. The usual thing that happens first all around the world if the application scales to a bigger usergroup is that the tech staff buys a new server and clusters it to handle the load. In many cases they also buy Server running as a load balancer to balance the requests between the two machines. If you have a look at the current specifications of smaller servers. They start with a 350 Watt power adapter. To calculate the energy costs of this example, I take this formula:
(for one server!)
Because you now have to servers to handle the load, we need to double this amount of work.
This is the same amount of energy you need to run your 1000W microwave oven 16.8 hours every day. This is much energy we waste just because our example code performs bad. I read the 1kWh is equal to 1.5L (Liter) of gas. So here’s the equivalent of gas we waste if our engine has an average efficiency of 25%:
Or 2755.75 L every year.
That’s like doing a 125 km drive every day with an average European car and that’s of CO2 every day or 6.4t CO2 a year. If it’s possible to optimize the code to run on one machine, then we could save these fumes and could save the costs for the two servers, the triple maintenance and the energy.
And we have millions of applications like that distributed around the world.
Think about it. Save money! Produce greener code.
Thank you.

5 Responses for "Bad code is killing earth"
You Fail: http://en.wikipedia.org/wiki/Jevons_paradox
It can killed earth really.
pretty lame, man. that’s the maximum load of 350w for a psu, not the effective.
Your general point is fair enough for large-scale applications processing lots of data on many servers. And here it makes sense to optimize the processing you need to do and find creative ways to avoid doing the processing you don’t.
But most computers (at homes, offices, etc.) are idle or near idle almost all the time, and they aren’t burning power because they’re busy running some application that we can optimize. It doesn’t matter if I write your word processor or web browser in C instead of Java, because 99% of the time it’s just waiting for you to type the next keystroke anyway.
A slight nitpick is that your numbers are too high. The 350W in a “350W Power Supply” is an upper bound for the power supply’s rated capacity; a typical home computer with one or two hard drives isn’t going to use more than 120 watts most of the time, then add 40 watts or so if you’re doing intense things like playing 3d games.
Lastly, you implicitly assume that energy production is harmful to the environment. That’s certainly true most of the time and in most places, but you can always build and use a clean energy source, if you’re willing to pay the price.
@Brad Walker
Thank you for the link. This paradox was unknown to me.
I’ll write about that later after some studying.
@lame
You are right. I missed a division by sqrt(2).
@ghettoimp
If you look at the desktop market and look what kind of grafikcards are used in modern PC just to render the eye candy of a 3D Desktop like Beryl or Aero then this is a problem. I installed Beryl once on my Workstation but quickly uninstalled it because the noisy van of my GPU drove me crazy. And that all just to render the desktop.
Any my intention is not to optimize to the last clock cycle. Design the applications well. Be careful with stuff like Hibernate that may end up in bad database performance. If you do this (what in my eyes is taken for granted) then you get better response times, your customer will be happy, your users will like you, you have better code to maintain, and finally you do a bit for the environment.
BTW: These numbers aren’t to high in my world. Some of my code is executed on machines draining up to 5.4kW. But they serve up to 3000 concurrent users with data. If you divide the consumption then these mainframes are tree-huggers…
Leave a reply