e.g. this study[1] in the UK puts "IT" as <6% of household electricity use, which is itself a fraction of a person's total energy use.
edit: and this[2] indicates that datacenter usage is also not very significant.
Therefore, no amount of optimising web pages will make a meaningful difference to carbon output.
As web professionals, it's better if we direct our focus towards more productive areas around this goal -- by e.g. donating to relevant campaign groups, or using our tech skills to produce media on the topic.
[1]: https://assets.publishing.service.gov.uk/government/uploads/...
[2]: https://www.iea.org/reports/data-centres-and-data-transmissi...
If I hypothetically ran an inefficient 500W dedicated server 24/7 for one 8760 hour year, and my electric utility produces 1 lbs of CO2 per kwh, that's about 2 tons of CO2 due to my programming habits per year.
Last year, I had a long commute and an inefficient vehicle. 1 gallon of gas produces 20 lbs of CO2, I got about 18 mpg, and drove 25,000 miles, mostly due to commuting, so my driving added 12.5 tons of CO2 to the atmosphere.
Instead of making my computing more efficient, I changed jobs and vehicles. Now I drive 2.5 miles to work, at 30 mpg, fill up maybe once a month instead of twice a week, and am much happier for it! If I spent extra time to do more efficient programming, I could have decimated my server's power bill, and could have saved almost 1.9 tons of CO2, but by spending that time looking for a better job and better commute, which were far more extreme, I saved about 10 tons of CO2 instead.
All of us only have a finite amount of time/attention we can spend on things like the environment. It we truly care, then it's our obligation to spend that time on the changes that have the biggest impact.
Let's discuss energy usage of the web once it makes its way into the top 100 areas of potential impactful improvement. Until then, let's put our effort into pressuring our politicians into enacting meaningful change where it matters.
And it's similar with computers, as you've stated (especially with Laptops that are already pretty energy efficient).
I'm not sure what we can do as web professionals honestly, but as technologists in general, maybe more of us can apply our engineering mindsets to actual climate change problems instead of building a 50th ad analytics platform.
Overall I'm not that concerned about our usage as it's not that bad and the industry is already rewarded for producing more efficient machines to compute.
That said, I've always thought it would be a cool project to use formal methods to prove efficiency properties or to quantify and prove the trade-offs between some more efficient algorithm and a greedier algorithm (especially in distributed systems.) But, most of that feels like developer mental masturbation in comparison to the much more egregious sorts of inefficiencies facing us (many of which require both social and technical solutions - the social one being the hardest.)
Sure your phone is using almost no power, but the network infrastructure and the servers you are using use a ridiculous amount of power.
Why does it matter? Isn't any improvement, by definition, a good thing?
If changing some of our programming methodologies saves 1% of the world's energy, that's massive.
1% of UK energy would be 22TWh — a massive amount of energy. Just because when it's expressed as a percentage it's only 1% doesn't mean it's not worthwhile.
Don't build websites on top of a million libraries which you don't need and put it in some container and host it in the cloud while using as much of the cloud service providers tools.
Build as much as possible from scratch and host it close to metal as possible.
The energy that we stand to save on the web, in the best case, is no more that the equivalent of a few points of GDP growth for some impoverished nation. It's less than negligible, it's net negative, because you are wasting the political and human energy optimizing irrelevant things and thinking you've made a difference.
Well, I think my employer doesn't care much about this topic, so I feel like you're talking very condescending to me, while I have little to no control over issues like this.
- The yearly energy savings of optimizing millions of web pages to reduce server side and local energy consumption?
- Banning personal vehicle diesel engines for 12 Months?
- Not shipping tonnes of tropical food across the Oceans for 12 months?
- Everybody not buying new clothes for 12 Months?
- Everybody not buying a new electronic device for 12 months?
I am not claiming that we should all go amish and bankrupt entire sections of the economy, my point is, these are all direct ways to curb carbon emissions but I have no intuition of how big of a dent in the overall emissions each option would make.
What are the carbon emissions that, if curbed, would provide the most bang for buck if you will?
Lack of knowledge of proper computer science fundamentals among blue collar developers is also a reason for this.
> "People just want to access content quickly, without distraction, without friction, and without it using a tonne of data."
Absolutely, most new websites for small businesses are 90% identical bloated single page scrolling Wordpress sites. When we visit those sites we're often looking for contact info, opening hours, menus, or maybe links to social media so we can interact with the company. So really we want ~100 bytes of data (e.g. address / socials / telephone / opening hours) but we have to download 5mb+
A small team and I have been working on an alternative to the web for structured data. It's a DNS-based protocol that domain / email owners can use to provide data direct to users:
https://www.num.uk https://news.ycombinator.com/item?id=24354559
Here is a list of how to be more resource efficient / cost effective:
1. Render dynamic assets to static html and cache them via a Content delivery network CDN. This will take far less cpu resources than rendering dynamic content and it will be faster to serve to the users.
2. Set reasonably long cache expire headers for content so that content are cached locally in the browser.
3. Use fast data structures such as hash-tables, tree structures that provides O(1), O(log n) lookup of your data whenever possible.
4. Use fast programming languages and frameworks such as Go-lang, C++, Rust, Scala and Java instead of slower languages. Fast programming languages uses less resources than slow programming languages.
5. This is one controversial since its not the current trend, but consider when to use Mini services / Monoliths instead of Micro services. A Monolith is a single process on one or more host it has access to local CPU cache and memory which is very fast. Mini services/Monolith will be more compute resource efficient than a Micro service where the service call has to be JSON serialized and travel over the network and then deserialized.
List of efficient web frameworks:
https://www.techempower.com/benchmarks/#section=data-r19&hw=...
List of search efficient data structures. Big Tech companies ask job interview questions on these data structures for reason of speed.
As to horrors of manual memory management - there are none as there is not a single place where my code explicitly allocates/deallocates memory. Modern C++ is pretty good in this department.
L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns
Compress 1K bytes with Zippy ............. 3,000 ns = 3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns = 20 µs
SSD random read ........................ 150,000 ns = 150 µs
Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs
Round trip within same datacenter ...... 500,000 ns = 0.5 ms
Read 1 MB sequentially from SSD* ..... 1,000,000 ns = 1 ms
Disk seek ........................... 10,000,000 ns = 10 ms
Read 1 MB sequentially from disk .... 20,000,000 ns = 20 ms
Send packet CA->Netherlands->CA .... 150,000,000 ns = 150 ms
Most of your code optimizations will pale in comparison to a single disk operation.So, maybe, you should buy more RAM? :)
STOP using gazillions of nested DIVs only to achieve a single button. I know this is the result of frameworks but maybe, just maybe, somebody someday will start making a clean layout framework that uses TABLE instead of DIV. It's sooooo f*ing much faster.
If I'm not mistaken, the internet uses as much power as all of Germany, or less than 100 million people. This makes our choices as individuals more important than our choices as developers.
Drive less, fly less, consume less.
All of this constant stringification/destringification just for another machine to read some transmitted data is massively wasteful, but we all do it because we want our data to be human readable, so we use JSON. But what if you could send as binary, with the ability to convert 1:1 to/from text only when you needed a human to inspect or input the data?
What if you didn't need to encode all of your non-numeric data into strings?
I've got many other steps in the pipeline to reduce our energy wastage, but this first one has taken awhile (3 years), and I still need more eyes on it to make sure nothing gets missed before I release in a few months.
At the dawn of the present mobile era, there was WebOS, which was built with web tech. The original iPhone unveil showed a phone that only supported web apps, and there was no App Store at all. Android came out of Google, a company that at that point depended completely on web APIs for rendering. Something clearly changed soon after that point, as web technologies were cast aside as the major mobile platforms evolved post-iPhone.
Many people ascribe this situation to nefarious motives on Apple's part, and I am aware of their artificial restrictions, including the requirement that other browsers use webkit, the click delay, limited hardware API/camera access, etc. Still, this alone doesn't explain why the other players (especially Google) ended up prioritizing non-web apps.
I hasten to add that something is definitely lost in the mobile app store model, namely the freedom of the user and of the content creator to put things on phones without filtering by reviewers. However, I think that issue is orthogonal to the energy efficiency discussion above. And I would be overjoyed to see this resolved in a way that enhances user and creator freedom, without any energy efficiency loss.
I have worked with web tech for years, before I quit writing web apps about a year ago. I have spent the last few months learning Swift and Metal, and I can see the relative strengths and weaknesses in both web and native app paradigms.
Given the above, I'd like to hear what you have to say:
- Did Apple deprecate web apps simply because they couldn't control them, or is there more to it than that, as the above suggests?
- Do web technologies have a bright future as a frontend application platform, or will they continue to be eclipsed on mobile devices by Swift and Kotlin, SwiftUI and Flutter? Will this trend continue as VR and AR adoption grows? Why or why not?
All of the inefficiency examples create unnecessary cost or worsen the user experience. It's well documented that most people work better and more often with fast tools. And there's lots of regular folks complaining that fashionable hipster websites are horrible to use. And lastly, lots of Javascript also increases maintenance costs.
So all of the points could be summarized as "don't make user hostile beginners' mistakes"
Now the more important question is: which company actually values its users / customers enough so that they won't outsource to the lowest bidder?
If you're running, say, a programming blog, stop sticking Google Analytics, "Like Me On Facebook", and any and all ads. If you've got a hankering to put the information out there, do that, and pretend it's like your old http://your.isp.com/~username web page. You don't need to fucking monetize it, it's a blog with your opinion which, like your asshole, is something everybody has one of.
Since we operate our tech stacks with batteries and often only solar/wind power, we try to come up with very energy conservative solutions.
One thing we couldn't do without: ARM CPUs even for servers, because they're quite energy efficient.
If you have any questions, i'll be checking this comment thread for a few days.
Same with energy. You don't _need_ your house to be "always on," etc. Turn out the light when you leave the room. Etc.
We could similarly not expect the sites to be "always on," and "instantly available," ready to deliver the highest-fidelity content as quickly as possible.
Yes, that keeps people engaged. But maybe we don't need more engagement. Maybe we have enough engagement going around.
https://hackaday.com/2018/10/08/perfecting-the-solar-powered...
Low-powered, on-demand, peer-to-peer, edge computing seems like a neat idea.
I'm not an economist though... I'm not really sure that websites contribute significantly to energy consumption.
If software were properly optimized, I wouldn’t need to upgrade my machinery. We’d need one fewer open cast mines to dig out rare earth metals. Less shipping. More recycling.
(Related, but tangential to web dev: device repair.)
I have no idea what I’m talking about though. I come to this site to find people who do.
The only way this is going to change is to change the hardware. I see this becoming possible as we transition to localized manufacturing where the individual only depends on themselves.
So as we get closer to chip fab happening via a 3d printer, and all hardware and software being local, we'll be closer to the energy efficiency goal.
You can see the trajectory already happening and IoT/Microcontroller/Etc boom. Lots of cool new projects are coming out with the "hacker-like" culture of old on energy efficient chips that can run amazing software powered by just solar alone.
Super cool, I have faith we'll get there soon!
The overwhelming majority of websites could be implemented with the exact same functionality with just html, and we are here because insane demand for websites created an insane wave of non knowledgable web "developers"
One suggestion, use 304 Not Modified when possible, this saves the client re-downloading a document as well as saving any more server side processing that might've been needed to create it.
Always wondered why 'popular' JS libraries simply aren't simply bundled in with browsers. Perhaps could be a problem of preferential treatment but I think if the top dozen or so libraries/versions were bundled in then that'd potentially save a lot of bandwidth, latency, CDN usage, etc...
For an app getting more than a couple page views in a session, a SPA solution may provide significant savings on rendering and db queries. Combine that with resource caching and these effects extend to following sessions.
That is, of course, if the app was built with some consideration regarding overall performance. Unfortunately, not too many web developers (both FE and BE) seem to be overly concerned with efficiency.
Nothing beats the feel of a static site loading in - so snappy and fast (especially if CSS has been adequately minified/bundled too).
I was expecting something like using serverless, or serving only static content or something.
There's just no way that "write less JavaScript" is the big needle mover compared to right sizing and scaling your fleet. Right?
Also, rather than spending two days optimizing all this, wouldn't you see much more carbon removed by spending two days planting trees?
You think these people will agree to optimize for energy savings? Not a chance, unfortunately.
That's interesting. It's more than I would have guessed. I assume that's dominated by the energy used by data centers and whatever devices the users are using, and that all the switches in between are relatively cheap to run relative to how much they're used?
Anyways, my suggestion is the obvious one: turn off all that ad and tracking nonsense. That's incompatible with the business model of a lot of popular sites, though. A good fallback may be to encourage everyone to use ad-blockers.
If it’s done by a trustworthy group and people start using it, we could have good information that could be used to understand what are sources of energy consumption over time from the point of view of users.
Again, that’s just an idea I got reading the comments here. And I know people here will dismiss it because of privacy concerns (that I mostly share).
* Block all third party script requests
* Never access the DOM via a selector (500x slower in Chrome and 20000x slower in Firefox)
* Stop relying on 1gb of code from NPM to do your job for you
Here is a small example:
For my blog site, I use Netlify to host - which auto deploys on a git push. My builds running on Netlify were averaging around 3 mins (every time I pushed whether it updated content or not).
I noticed the problem when I almost ran out of build time. So I changed it to build locally and now commit the build output inside my git repo. Netlify deploys in around 5 secs now since it is all pre-built static files - I’ll never run out of build time now.
My machine already has all the dependencies and cached build output, so it can build in about 20 secs.
In addition, I can handle build errors immediately rather than finding a failed deployment.