The ecological cost of slow software
2021-01-27 tech angry-rantsIntroduction
Every now and then, there’s another discussion on social media on why software nowadays is just so damn slow. There’s typically two types of responses to that question:
- “Software does so much more than 20 years ago”
- “Developer time is so much more expensive than CPU time that developing fast software isn’t cost-efficient”
I’m not going into too much detail on point one, except that I strongly disagree. From and end-user-perspective,
Facebook, Twitter or Reddit don’t really do that much more than myspace or the guestbooks of the 90s.
Sure, they process a bit more data, and yes the data is stored hierarchically in groups or subreddits, instead of just linearly.
But in the end: Website shows comments, users respond. Not exactly rocket surgery.
One of the few expensive things that they do is of course advertising/tracking. But that’s not exactly a feature.
The second point is much more interesting in my opinion, especially because it’s not quite as obviously false.
It’s a pretty simple economic argument, and it makes sense at first glance:
Having a someone spending a few days optimizing your software quickly costs in the four to five digit Euros1. A virtual machine with 10 cores, 64GB RAM and few TB of SSD storage costs below 50 Euro/month at my preferred ISP. In many cases, just throwing more hardware at a problem seems pretty sensible.2
Externalities
But why is writing non-crappy software so much more expensive?
To be able to explain this, we need to look into externalities. An externality is defined by wikipedia as “cost or benefit that is imposed on a third party who did not agree to incur that cost or benefit.”
In backends
As an example: I don’t develop software that’s internally used by my employer. Instead, the company provides software development as a service. If the software I develop is slow and scales badly, it’s not me or my employer that has to pay for bigger servers, it’s my customer. That seem to be a pretty common situation in software development.
The customer could of course mandate performance requirements for his software, but not all do. In some cases, the customer honestly just doesn’t care, as long as the software scales horizontally.
Some of the actual cost of using/deploying the software may well be an externality for our customer, too: That’s an often discussed topic in the context of climate change. If I buy a few EC2 instances, I’m basically only paying for electricity and bandwidth. Without the presence of CO2 taxes, the ecologic cost of my VMs is not being paid by me - its being paid collectively by everyone alive a few decades to centuries from now.
In frontends
An even more egregious case of externalities is typical (web-)frontend development. Frontend-code runs on the end-users machines. That’s not me or my customer, so there’s no reason for us to really care until the users complain. And internet users nowadays don’t expect web UIs to be fast. Look at reddit: Performance-wise, the current endless-scrolling-design is a complete shitshow. I’m using a seriously beefy workstation, and browsing reddit3 is as expensive in terms of CPU load as the entire test infrastructure for some of my customers, involving a Kubernetes cluster with a handful of deployments. On my “older” 2015 MacBook Pro, browsing reddit for more than an hour or so often just fully locks up my browser.
I often hear people say that their computers are old, and are getting slower. That’s of course not true - the computer is exactly as fast as 5 years ago, applications and websites are just more resource-hungry.
This leads to people throwing away perfectly fine computers and buying new ones.
This leads to externality #1: End users spend hundreds or thousands of euros on new hardware.
But that’s not the end of it. New computers don’t just appear out of thin air. They’re built somewhere and transported to our end users.
Externality #2: CO2 emissions due to transport.
And who’s manufacturing all the electronics? Companies like Foxconn, who are repeatedly reported to have working conditions bordering on slave-labor [1] [2] [3].
Externality #3a: Slave labor in China.
Where do the materials come from? Rare earths are again commonly mined in china. Cobalt, used in batteries, is commonly mined in Congo. Again using slave labor.
Externality #3b: Slave labor outside of China.
Note that in both “slave labor” arguments, the workers may well be children. Maybe small hands are beneficial in some industries, maybe it’s practical to use people who are too small/weak to resist. Maybe there’s an economic benefit to use laborers that don’t eat much. Maybe the families just can’t survive without sending their children to Work. Maybe it’s just easier, legally speaking.
Regardless of the reasons: Externality #3c: Child-slave-labor.
And how to the mining and manufacturing processes look, apart from humanitarian questions? Still bad. There’s lots of toxic chemicals involved in electronics production[1] [2], and they have to be disposed of somewhere.
Externality #4: Toxic pollution during manufacturing
Then there’s the question where old computers go. Typically: In the trash. Selling an older computer usually isn’t worth it - electronics fall in value rather quickly. And selling the machine would take effort and time, and time is the one thing nobody has. So the devices - even working ones - often just get disposed of. That trash is then commonly shipped to…. well somewhere else, because you wouldn’t want to do all the recycling in your own country, would you? Half of that stuff’s poison!
No, really: For large-scale electronics “recycling”, you go to places like Agogbloshie, Ghana.
Externality #5: Toxic pollution during recycling.
Even when we completely disregard the issue of new computers having to be bought to deal with slow software, there’s one more thing: Website bloat.
The topic in general should be well-known by now, and is explained quite well in an article by Joshua Bixby and an article / talk by Maciej Cegłowski.
TL;DR: Websites are getting bigger: Transferring over 10MB for the initial pageload for a new site - regardless of how little actual content they contain - is becoming more common.
And transmitting data over a network takes some amount of energy, which of course again involves CO2 emissions. The actual cost per GB of traffic is difficult to estimate, and changes with time. I’m going with This article from 2017, by Aslan et al, specifically figure 3. That estimates an energy usage between 0.023 and 0.06 kWh/GB in 2015.
Using reddit as an example:
Worthofweb.com estimates about 460 million pageviews per month for reddit. Combined and personal observations regarding page size (conservatively: roughly 330kb transfer per pageview for posts), this leads to roughly 4PB of traffic per month, or an average sustained energy usage between 0.14 and 0.36 megawatt, depending on the estimate used for energy usage per GB transferred. With the European energy mix at 275 g of CO2 per kWh, according to the EEA, that’s about 335 to 870 metric tons of CO2 per year. The larger number being “only” 0.1% of the yearly CO2 output of Somalia or 0.0022% of that of Switzerland, but still. Literally tons of CO2 to transfer what amount to a few lines of text. Again, this is traffic only. Running the actual backend is a different matter entirely, probably generating a few orders of magnitude more.
Externality #6: CO2 emissions due to internet traffic.
Conclusion
I wouldn’t go as far as saying that writing slow software is literally the same as murder. But I kind of wish that Greenpeace, or their less radical alternatives, would.
Note that the arguments applied under the ‘frontend’ heading also apply to slow, crappy backends. But I think they’re less critical there. More on that when I talk about solutions.
Solutions
So how do we fix this?
No idea.
Honestly, I think as software developers: We don’t.
If I were to spend four times as long writing fast code, while other developers just quickly write adequate code, I expect I would be unemployed within months. That’s not even a jab at my employer. No customer is willing to pay for that. And why should they? They’re not paying the costs of slow software. That’s the entire point of this post!
The only thing that really could help would be regulation.
But that’s also risky. How would one even start to define legal performance or efficiency requirements for software? And any country with such regulation for local developers would be economically disadvantaged enough that no significant amount of commercial software could be developed there any more.
A country with such regulations for websites and imported software would need infrastructure to prevent non-compliant software and websites being used. That’s pretty much the same tooling used for China-style internet censorship.
And doing this globally, everywhere at the same time… Apart from being logistically impossible, I expect this would lead to further monopolization. Small companies aren’t going to be able to afford the time and the type of employees needed to comply with such regulation.
I previously claimed that I think that externalities in backends are less problematic. Why would I say such a thing?
I could imagine not regulating slow software, but non-ethically sourced or just plain environmentally dirty hardware. High taxes or outright bans on things built using slave labor, and making the manufacturer directly responsible for (relatively clean) recycling could work.
And companies that deploy slow backend applications would be hit be the cost almost immediately. That could create some real pressure. On the frontend-side, however… The cost would again just hit the end-user, and for that to create pressure on actual developers would take time.
I, for one, am probably just going to do nothing and just watch while everything goes to shit. I’m pretty misanthropic, so that’s been a pretty successful strategy for me over the last decades.
Example calculation: Rates of 110 Euro/hour or more are not that unusual for consultants in my region, so spending “just” three 8h-days is easily going to cost over 2500 Euro. Internally employed developers are not that much cheaper. ↩︎
Combined with the previous footnote, that means instead of spending a three person-days doing optimization, we could add 4 moderately large VMs to our deployment environment for just over a year. Any serious, large scale work on performance would need massive improvements to be worth it financially. ↩︎
I’m repeatedly using reddit as an example, not because this is some kind of hit piece, but because I actually use reddit. I’m sure I’d be similary annoyed about facebook, twitter, parler, and so on, were I to use those. ↩︎