How Green Is Your Code
When we read of computers and the environment, stories generally focus on the world’s poorer of the poor picking through our discarded gadgets in an attempt to recycle any loose bits that might earn them a living.
E-waste horror stories come to us via China an India where day laborers are paid single digit dollars to scour through trash heaps of mecury, lead, cadmium and beryllium in search of something “recyclable”. This leads to all sorts of health risks ranging from cancer to developmental defects.
60 Minutes Report on e-Waste
On the positive side we also hear of innovative programs to reduce the carbon footprint of server farms. Developing and deploying more energy efficient machines in the first place is one strategy. So too efforts to use alternative energies to run them in the first place. To date one of our favorites is harnessing offshore tidal flows. Two Scottish server farms show us how this is done. Google even filed a patent for “water-based data centers.” The idea here is that offshore data barges will use the ocean to power and cool their thousands upon thousands of servers.
What flies well under the radar — if it even flies at all — is the underlying code that makes our digital lifestyle possible.
Code: the poetry that forms the software and processes that make possible every tweet, blog post, VoIP call and e-commerce exchange comes in a variety of languages with fanciful names. There’s Java, Rails, PHP, Django and Cocoa to name a few. So too an allegiance to the letter ‘C’ with C, C+, C++ and even C#.
There are many more of course and they drive our gaming consoles, Facebook friends, smart phones and the apps that make our smartphones so delightful.
But how green is this code?
By its nature, code is simply funny looking, text-based language to the uninitiated, and the generator of vitriolic flame wars by its practitioners (think: Coke v Pepsi, MacDonald’s v Burger King, Taste Great v Less Filling).
Those that write code do so line by line to create applications, and the code base for any given application can range from a few to millions of lines.
What happens next is that the code is processed and compiled by machines, be they personal computers, phones or dedicated devices such as Amazon’s Kindle e-reader. And that compiling takes processing power. Power, in this case, requiring energy. Energy, in this case, coming from our national grids. Our national grids, in this case, powered mostly by our carbon fuels.
End users the likes of you and I don’t much care what programming language might be used to make our Blackberries and iPhones phone home. It’s not a factor we take into account when we buy PS3’s or Xbox’s.
We don’t give it a second thought when we listen to Pandora or Last.fm.
What we do consider lies more along the lines of maximizing economies of awesome: how smooth does the application or Web site or console or device run; what eye candy does it have that wows us; does it deliver on the promise of doing what it says it will do. Simply, few of us look under the hood and say, “Know what, I’m not going to use this Web site because it’s Java instead of PHP.”
The idea of choosing so is on its face comical.
Developers, on the other hand, have different criteria. It matters very much to them what language they program in. Engage them a bit, give them a few beers, and you’ll hear passionate rationales about why Twitter is Rails, Facebook is PHP, most of our banking sites are Java and on and on.
The decisions made are similar to any creator choosing a toolkit to actualize a vision, be it chef in a kitchen, artisan in the studio or artist before a canvas. What language will best let them create a particular vision. What language will best let them iterate over and expand this vision. What, simply, gives them the most bang for the buck with the least friction and headache.
Those are the considerations Code Ninjas take into account.
Programming choices, it seems, are very much like most life choices.
But many life choices these days take another factor into account: the environmental impact of the decision made, be it a more fuel efficient car or whether to use a car at all.
Could that, would that, ever happen in the world of code?
Recently, Amin Vahdat, Professor of Computer Science and Engineering at UC San Diego, had a behind the scenes peek at Facebook’s ever expanding server farms. As he outlines in a post, Facebook has 200 billion monthly page views, over 3.9 trillion feed actions per day, stores over 20 billion photos and delivers over 600,000 photos per second. That’s just the tip of the iceberg and it demonstrates how much sheer computing power the company needs to stay up and running.
As said, power means energy means carbon fuels. And the computer power Facebook currently uses runs something along the lines of 30 thousand servers. While Vahdat writes that many of the back-end, intensive processes are written in C++, Facebook as a Web site is largely driven by PHP.
Enter a follow-up post over at WebToolKit, a C++ blog. Here they run some numbers and conclude that Facebook servers, its cooling mechanisms and other overhead produce approximately 59,000 tons of CO2 per year.
To put this number in perspective: The entire CO2 emission of the USA is 5,752,289,000 tons of CO2 per year and 66,693,000 ton for Finland. So, this server park emits an amount of CO2 that is about 1/1000 of the total of CO2 emissions by Finland. I would argue that is not quite negligible.
The numbers are remarkable, especially when you consider WebToolKit’s argument that if Facebook moved away from PHP, it could eliminate 22,500 servers and reduce its annual carbon footprint by 49,000 tons.
Move our minds away from Facebook and onto the gadgets we use every day. More efficient code on our phones means we’d recharge less frequently. Ditto our laptops. Ditto everything digital we use day today. While it might not mean much on a per user basis, the economies of scale are staggering. Simply think of the billions of cellphones, computers and gadgets in circulation across the planet.
Which brings us back to our Code Ninjas. What will bring about the day when how green and clean our code is is as important to our decisions as what that code can actually do? Will benchmarks be introduced to guide such decisions? Will there be a type of digital LEED certification system for code? We are, after all, building architectures of a distinct — if virtual — type.
Businesses elsewhere debate and struggle with the issue. So too, and never to soon, should we too.
Image: By Rainforest Harley via Flickr
Originally published at ScribeMedia.org